|
@@ -93,10 +93,11 @@ public class UploadToOssUtil {
|
|
|
|
|
|
/**
|
|
|
* oss文件上传命令
|
|
|
- * 第一个参数是oss路径,要包含bucket名称
|
|
|
- * 第二个参数是本地文件路径
|
|
|
+ * 第1个参数是本地文件路径
|
|
|
+ * 第2个参数是oss路径
|
|
|
+ * 第3个参数是bucket名
|
|
|
*/
|
|
|
- private static final String UPLOAD_SH = "bash /opt/ossutil/upload.sh %s %s";
|
|
|
+ private static final String UPLOAD_SH = "bash /opt/ossutil/upload.sh %s %s %s";
|
|
|
|
|
|
//上传的数据是byte[],key是上传后的文件名
|
|
|
public void upload(byte[] data,String key1) throws IOException{
|
|
@@ -136,14 +137,13 @@ public class UploadToOssUtil {
|
|
|
* @param key
|
|
|
*/
|
|
|
public void uploadBySh(String bucket, String filePath, String key) {
|
|
|
- String ossPath = this.bucket + "/" + key;
|
|
|
try {
|
|
|
- String command = String.format(UploadToOssUtil.UPLOAD_SH, ossPath, filePath);
|
|
|
- log.info("开始上传文件, ossPath:{}, srcPath:{}", ossPath, filePath);
|
|
|
+ String command = String.format(UploadToOssUtil.UPLOAD_SH, filePath, key, bucket);
|
|
|
+ log.info("开始上传文件, ossPath:{}, srcPath:{}", key, filePath);
|
|
|
CreateObjUtil.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);
|
|
|
}
|
|
|
}
|