测试编译class文件
parent
fba9f67e27
commit
ed5ef7817c
|
@ -182,7 +182,7 @@ public class EngineVersionController extends BaseController {
|
|||
public boolean insertVersion(@RequestBody EngineVersion engineVersion) {
|
||||
log.info("数据是:{}"+engineVersion.getRuleContent());
|
||||
OssUpload.uploadFiles(engineVersion.getRuleContent(), engineVersion.getVersionCode());
|
||||
OSSFileDownload.localDownload();
|
||||
OSSFileDownload.streamingDownload(engineVersion.getName());
|
||||
JavaClass.compile(engineVersion.getName());
|
||||
engineVersion.setId(null);
|
||||
boolean insert = engineVersionService.insert(engineVersion);
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.muyu.javacomplier;
|
|||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.model.GetObjectRequest;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.muyu.domain.constants.Result;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -19,17 +21,28 @@ public class OSSFileDownload {
|
|||
|
||||
private static final String fileName = "engine";
|
||||
|
||||
public static void localDownload() {
|
||||
try {
|
||||
public static Result<Object> streamingDownload(String fileName) {
|
||||
|
||||
String source = null;
|
||||
// 创建 OSSClient 实例
|
||||
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
// 下载Object到本地文件,并保存到指定的本地路径中。如果指定的本地文件存在会覆盖,不存在则新建。
|
||||
// 如果未指定本地路径,则下载后的文件默认保存到示例程序所属项目对应本地路径中。
|
||||
ossClient.getObject(new GetObjectRequest(bucketName, fileName), new File(filePath));
|
||||
// 关闭OSSClient。
|
||||
// 判断 bucket 是否存在
|
||||
Boolean flag_bucket = ossClient.doesBucketExist(bucketName);
|
||||
if (!flag_bucket) {
|
||||
System.out.println("bucket不存在");
|
||||
return Result.error("bucket不存在");
|
||||
}
|
||||
String objectName = fileName + ".java";
|
||||
Boolean flag_file = ossClient.doesObjectExist(bucketName, filePath + objectName);
|
||||
if (!flag_file) {
|
||||
System.out.println("预下载文件不存在");
|
||||
return Result.error("预下载文件不存在");
|
||||
}
|
||||
// 本地文件下载路径
|
||||
String localPath = "home/" + objectName;
|
||||
ObjectMetadata object = ossClient.getObject(new GetObjectRequest(bucketName, filePath + objectName), new File(localPath));
|
||||
System.out.println(object);
|
||||
ossClient.shutdown();
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
return Result.success(source);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue