|
@@ -57,11 +57,12 @@ function ftlUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,d
|
|
|
//将中文——转换为英文-
|
|
|
fileName = fileName.replace(/—/g,"-")
|
|
|
fileName = fileName.replace("……","")
|
|
|
+ fileName = fileName.replace("±","")
|
|
|
var dfl=new File([file],fileName,{type:file.type});
|
|
|
file = dfl
|
|
|
/*console.log(file.name.indexOf("—")!=-1);
|
|
|
console.log("-----------------------start");*/
|
|
|
- ftlMultitest(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt);
|
|
|
+ ftlMultitest(client,storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt);
|
|
|
};
|
|
|
|
|
|
function multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt) {
|
|
@@ -78,14 +79,15 @@ function multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,upload
|
|
|
//将中文——转换为英文-
|
|
|
fileName = fileName.replace(/—/g,"-")
|
|
|
fileName = fileName.replace("……","")
|
|
|
+ fileName = fileName.replace("±","")
|
|
|
var dfl=new File([file],fileName,{type:file.type});
|
|
|
file = dfl
|
|
|
/*console.log(file.name.indexOf("—")!=-1);
|
|
|
console.log("-----------------------start");*/
|
|
|
if(cpt == 1)
|
|
|
- multitestFlag(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt,"",prefix);
|
|
|
+ multitestFlag(client,storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt,"",prefix);
|
|
|
else
|
|
|
- multitest(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt);
|
|
|
+ multitest(client,storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt);
|
|
|
};
|
|
|
function multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt,idx,prefix,currentUser) {
|
|
|
|
|
@@ -105,6 +107,7 @@ function multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,upload
|
|
|
//将中文——转换为英文-
|
|
|
fileName = fileName.replace(/—/g,"-")
|
|
|
fileName = fileName.replace("……","")
|
|
|
+ fileName = fileName.replace("±","")
|
|
|
var dfl=new File([file],fileName,{type:file.type});
|
|
|
file = dfl
|
|
|
|
|
@@ -162,12 +165,22 @@ function fBmultipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uplo
|
|
|
//将中文——转换为英文-
|
|
|
fileName = fileName.replace(/—/g,"-")
|
|
|
fileName = fileName.replace("……","")
|
|
|
+ fileName = fileName.replace("±","")
|
|
|
var dfl=new File([file],fileName,{type:file.type});
|
|
|
file = dfl
|
|
|
|
|
|
requestUrl = realPath+"/previewController/getAccess";
|
|
|
OSS.urllib.request(requestUrl, {method: 'GET'}, function (err, response) {
|
|
|
if (err) {
|
|
|
+ console.log(err);
|
|
|
+ $.ajax({
|
|
|
+ type:"post",
|
|
|
+ url:realPath+"/previewController/saveJSError",
|
|
|
+ data:{object:err.toString()},
|
|
|
+ async: false,
|
|
|
+ success:function(data){
|
|
|
+ }
|
|
|
+ });
|
|
|
return alert(err);
|
|
|
}
|
|
|
try {
|
|
@@ -592,6 +605,7 @@ function multitest (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadP
|
|
|
'<div class="op-btn-box">' +
|
|
|
'<a href="javascript:location.href=\''+realPath+'/a/workfullmanage/workFullManage/downLoadAttach?file=\'+encodeURIComponent(\''+data.url+'\');" class="op-btn op-btn-download"><i class="fa fa-download"></i> 下载</a>'+
|
|
|
'<a href="javascript:void(0)" onclick="deleteFileFromAliyun(this,\''+realPath+'/a/sys/workattachment/deleteFileFromAliyun?url='+encodeURIComponent(data.url)+'&id='+data.id+'&type=2\',\''+addFile+'\',\''+divId+'\')" class="op-btn op-btn-delete" ><i class="fa fa-trash"></i> 删除</a>'+
|
|
|
+ /*'<a href="javascript:void(0)" onclick="ossCollectingAccessory(this,\''+realPath+'/projectAccessory/projectAccessory/ossCollectAccessory?url='+data.url+'&fileName='+data.attachmentName+'\',\''+addFile+'\',\''+divId+'\')" class="op-btn op-btn-delete" ><i class="fa fa-trash"></i> 收藏</a>'+*/
|
|
|
'</div>' +
|
|
|
'</td>'+
|
|
|
'</tr>';
|
|
@@ -854,3 +868,104 @@ function deleteFileFromAliyun(obj,deleteUrl,addFile,divId){
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+function fileCollectAccessory(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt) {
|
|
|
+ file.name.replace(" ","")
|
|
|
+ file.name.replace(/—/g,"")
|
|
|
+ var fileName = file.name;
|
|
|
+ // 将单引号‘’都转换成',将双引号“”都转换成"
|
|
|
+ fileName = fileName.replace(/\’|\‘/g,"'").replace(/\“|\”/g,"\"");
|
|
|
+ // 将中括号【】转换成[],将大括号{}转换成{}
|
|
|
+ fileName = fileName.replace(/\【/g,"(").replace(/\】/g,")").replace(/\{/g,"(").replace(/\}/g,")");
|
|
|
+ fileName = fileName.replace(/\[/g,"(").replace(/\]/g,")").replace(/\{/g,"(").replace(/\}/g,")");
|
|
|
+ // 将逗号,转换成,,将:转换成:
|
|
|
+ fileName = fileName.replace(/,/g,",").replace(/:/g,":");
|
|
|
+ //将中文——转换为英文-
|
|
|
+ fileName = fileName.replace(/—/g,"-")
|
|
|
+ fileName = fileName.replace("……","")
|
|
|
+ fileName = fileName.replace("±","")
|
|
|
+ var dfl=new File([file],fileName,{type:file.type});
|
|
|
+ file = dfl
|
|
|
+ requestUrl = realPath+"/previewController/getAccess";
|
|
|
+ OSS.urllib.request(requestUrl, {method: 'GET'}, function (err, response) {
|
|
|
+ if (err) {
|
|
|
+ console.log(err);
|
|
|
+ $.ajax({
|
|
|
+ type: "post",
|
|
|
+ url: realPath + "/previewController/saveJSError",
|
|
|
+ data: {object: err.toString()},
|
|
|
+ async: false,
|
|
|
+ success: function (data) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return alert(err);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ result = JSON.parse(response);
|
|
|
+ } catch (e) {
|
|
|
+ errmsg = 'parse sts response info error: ' + e.message;
|
|
|
+ return alert(errmsg);
|
|
|
+ }
|
|
|
+ console.log("---------result" + result);
|
|
|
+ client = new OSS.Wrapper({
|
|
|
+ accessKeyId: result.AccessKeyId,
|
|
|
+ accessKeySecret: result.AccessKeySecret,
|
|
|
+ stsToken: result.SecurityToken,
|
|
|
+ bucket: result.Bucket,
|
|
|
+ endpoint: result.Endpoint,
|
|
|
+ timeout: '30000'
|
|
|
+ });
|
|
|
+ storeAs = "attachment-file/" + storeAs + "/" + today + new Date().getTime() + file.name;
|
|
|
+ collectAccessory(client, storeAs, file, attachmentId, attachmentFlag, uploadPath, divId, size, cpt);
|
|
|
+ })
|
|
|
+};
|
|
|
+
|
|
|
+function collectAccessory (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,cpt) {
|
|
|
+
|
|
|
+ var names = storeAs.split("/");
|
|
|
+ var name = names[names.length-1];
|
|
|
+ ossClient.multipartUpload(storeAs, file,{
|
|
|
+ partSize: 1 * 1024 * 1024,
|
|
|
+ parallel: 5,
|
|
|
+ progress: function* (percent, cpt) {
|
|
|
+ var p = Math.floor(percent*100);
|
|
|
+ $("#jindutiao"+divId).attr("style","width: "+p+"%");
|
|
|
+ $("#jindutiao"+divId).attr("aria-valuenow",p+"%");
|
|
|
+ $("#baifenbi"+divId).html(p+"%");
|
|
|
+ checkpoint_temp = cpt;
|
|
|
+ }
|
|
|
+ }).then(function (result) {
|
|
|
+ var fileLocation = "";
|
|
|
+ var lookUrl = "";
|
|
|
+ //获取文件存储位置(0:本地;1:百度云;2:阿里云)
|
|
|
+ $.ajax({
|
|
|
+ type:"get",
|
|
|
+ url:realPath+"/bos/getFileStorageLocation",
|
|
|
+ async: false,
|
|
|
+ success:function(data){
|
|
|
+ fileLocation = data.fileLocation;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ returnUrl = realPath+"/collectAccessory/collectAccessory/saveCollectAccessory";
|
|
|
+ $.ajax({
|
|
|
+ type:'post',
|
|
|
+ url:returnUrl,
|
|
|
+ data:{
|
|
|
+ "fileName":file['name'],
|
|
|
+ "url":"/"+storeAs,
|
|
|
+ "type":"1"
|
|
|
+ },
|
|
|
+ success:function(data){
|
|
|
+ if(data.success){
|
|
|
+ parent.layer.msg("上传成功!",{icon:1});
|
|
|
+ location.reload();
|
|
|
+ }else {
|
|
|
+ parent.layer.msg("上传失败!",{icon:2});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(function (err) {
|
|
|
+ console.log("err------ err:");
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+};
|