11111
parent
7ad71f5f61
commit
99f7ba1a23
|
@ -1,5 +0,0 @@
|
||||||
public class HelloWorld {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println("Hello, World!");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -178,10 +178,12 @@ public class OssUtil {
|
||||||
// 创建OSSClient实例。
|
// 创建OSSClient实例。
|
||||||
OSS ossClient = new OSSClientBuilder().build(endPoint,accessKeyId,accessKeySecret);
|
OSS ossClient = new OSSClientBuilder().build(endPoint,accessKeyId,accessKeySecret);
|
||||||
|
|
||||||
try (OSSObject ossObject = ossClient.getObject(new GetObjectRequest(bucketName, objectName))) {
|
try {
|
||||||
|
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, objectName);
|
||||||
|
OSSObject ossObject = ossClient.getObject(getObjectRequest);
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent()));
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
String line;
|
String line=null;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
content.append(line).append("\n");
|
content.append(line).append("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ package com.muyu.rule.server;
|
||||||
|
|
||||||
import com.aliyun.oss.OSS;
|
import com.aliyun.oss.OSS;
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
|
import com.aliyun.oss.model.GetObjectRequest;
|
||||||
|
import com.aliyun.oss.model.OSSObject;
|
||||||
import com.aliyun.oss.model.PutObjectRequest;
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
import com.muyu.rule.common.domain.DataValue;
|
import com.muyu.rule.common.domain.DataValue;
|
||||||
import com.muyu.rule.common.utils.OssUtil;
|
import com.muyu.rule.common.utils.OssUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -36,6 +36,8 @@ public class DataTest {
|
||||||
|
|
||||||
private static String bucketName = "zcz-vfd-1000";
|
private static String bucketName = "zcz-vfd-1000";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
String sourceCode ="public class HelloWorld {\n" +
|
String sourceCode ="public class HelloWorld {\n" +
|
||||||
|
@ -59,10 +61,31 @@ String sourceCode ="public class HelloWorld {\n" +
|
||||||
|
|
||||||
// 关闭OSSClient。
|
// 关闭OSSClient。
|
||||||
ossClient.shutdown();
|
ossClient.shutdown();
|
||||||
//读取
|
|
||||||
String s = OssUtil.readFileContentFromOSS(bucketName, "test");
|
|
||||||
|
|
||||||
System.out.println(s);
|
// 创建OSSClient读取实例。
|
||||||
|
OSS ossClientReader = new OSSClientBuilder().build(endPoint,accessKeyId,accessKeySecret);
|
||||||
|
|
||||||
|
try {
|
||||||
|
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, "test");
|
||||||
|
OSSObject ossObject = ossClientReader.getObject(getObjectRequest);
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent()));
|
||||||
|
StringBuilder content = new StringBuilder();
|
||||||
|
String line=null;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
content.append(line).append("\n");
|
||||||
|
}
|
||||||
|
System.out.println("读出的内容{}[]:"+content);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("读取失败:" + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
// 关闭OSSClient。
|
||||||
|
ossClient.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineVersionMapper,R
|
||||||
* 将java源码存入OSS
|
* 将java源码存入OSS
|
||||||
*/
|
*/
|
||||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(versionClazz.getBytes());
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(versionClazz.getBytes());
|
||||||
OssUtil.uploadFileInputStreamForBucket(bucketName,className,byteArrayInputStream);
|
OssUtil.uploadFileInputStreamForBucket(bucketName,className+Suffix_JAVA,byteArrayInputStream);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
public class HelloWorld {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println("Hello, World!");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue