master
chentaisen 2024-09-05 16:20:28 +08:00
parent a056d109f2
commit 8bbcc0882d
2 changed files with 26 additions and 24 deletions

View File

@ -65,6 +65,8 @@ public class RuleEditionController {
//java OSS
UploadOss.uploadFiles(ruleEdition.getRuleEngine(), ruleEdition.getRuleKind());
OSSFileDownload.streamingDownload(ruleEdition.getRuleKind());
OSSFileDownload.compile(ruleEdition.getRuleKind());
// //对路径里的.java文件进行编译

View File

@ -23,30 +23,30 @@ public class OSSFileDownload {
private static final String filePath = "oss/";
// public static Result<Object> streamingDownload(String fileName) {
//
// String source = null;
// // 创建 OSSClient 实例
// OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
// // 判断 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();
// return Result.success(source);
// }
public static Result<Object> streamingDownload(String fileName) {
String source = null;
// 创建 OSSClient 实例
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
// 判断 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();
return Result.success(source);
}
public static Result<Object> compile(String fileName) {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();