|
@@ -87,6 +87,8 @@ public class UploadToOssUtil {
|
|
|
*/
|
|
|
private static final String UPLOAD_SH = "bash /opt/ossutil/upload.sh %s %s";
|
|
|
|
|
|
+ public static final String FYUN_UPLOAD = "sudo bash /opt/ossutil/fyun-upload.sh %s %s /%s %s %s";
|
|
|
+
|
|
|
//上传的数据是byte[],key是上传后的文件名
|
|
|
public void upload(String bucket, byte[] data,String key1) throws IOException{
|
|
|
log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , new String(data, "UTF-8"),key1,type);
|
|
@@ -125,14 +127,13 @@ public class UploadToOssUtil {
|
|
|
* @param key
|
|
|
*/
|
|
|
public void uploadBySh(String bucket, String filePath, String key) {
|
|
|
- String ossPath = bucket + "/" + key;
|
|
|
+ String command = String.format(FYUN_UPLOAD, bucket, filePath, key, type, "file");
|
|
|
try {
|
|
|
- String command = String.format(UploadToOssUtil.UPLOAD_SH, ossPath, filePath);
|
|
|
- log.info("开始上传文件, ossPath:{}, srcPath:{}", ossPath, filePath);
|
|
|
+ log.info("开始上传文件, ossPath:{}, srcPath:{}", key, filePath);
|
|
|
callshell(command);
|
|
|
- log.info("上传文件完毕, ossPath:{}, srcPath:{}", ossPath, filePath);
|
|
|
+ log.info("上传文件完毕, ossPath:{}, srcPath:{}", key, filePath);
|
|
|
} catch(Exception e) {
|
|
|
- log.error("上传文件失败, ossPath:{}, srcPath:{}", ossPath, filePath);
|
|
|
+ log.error("上传文件失败, ossPath:{}, srcPath:{}", key, filePath);
|
|
|
log.error("上传文件失败", e);
|
|
|
}
|
|
|
}
|