|
@@ -222,28 +222,28 @@ public class ViewController extends Controller {
|
|
|
|
|
|
OSS OSS_CLIENT = new OSSClientBuilder().build(PropKit.get("oss_endpoint"), PropKit.get("oss_accessKey"), PropKit.get("oss_secretKey"));
|
|
|
|
|
|
-// String fileNameStr[] = filePath.split("/");
|
|
|
-// String fileName = fileNameStr[fileNameStr.length - 1];
|
|
|
-// String fileStorePath = getFileWithUrl(filePath, fileName);
|
|
|
-// File file = new File(fileStorePath);
|
|
|
-// String key = PropKit.get("institution_id") + "/" + fileName;
|
|
|
-// InputStream inputStream = null;
|
|
|
-// try {
|
|
|
-// inputStream = new FileInputStream(fileStorePath);
|
|
|
-// } catch (FileNotFoundException e) {
|
|
|
-// // TODO Auto-generated catch block
|
|
|
-// e.printStackTrace();
|
|
|
-// renderText(e.toString());
|
|
|
-//
|
|
|
-// }
|
|
|
-// Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
-// if (!eBoolean) {
|
|
|
-// OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, inputStream);
|
|
|
-// Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
-// if (bBoolean) {
|
|
|
-// file.delete();
|
|
|
-// }
|
|
|
-// }
|
|
|
+ String fileNameStr[] = filePath.split("/");
|
|
|
+ String fileName = fileNameStr[fileNameStr.length - 1];
|
|
|
+ String fileStorePath = getFileWithUrl(filePath, fileName);
|
|
|
+ File file = new File(fileStorePath);
|
|
|
+ String key = PropKit.get("institution_id") + "/" + fileName;
|
|
|
+ InputStream inputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = new FileInputStream(fileStorePath);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ renderText(e.toString());
|
|
|
+
|
|
|
+ }
|
|
|
+ Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+ if (!eBoolean) {
|
|
|
+ OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, inputStream);
|
|
|
+ Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+ if (bBoolean) {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
renderText("succ");
|
|
|
|
|
|
} catch (Exception e) {
|