|
@@ -129,11 +129,17 @@ function multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,upload
|
|
timeout:'30000'
|
|
timeout:'30000'
|
|
});
|
|
});
|
|
storeAs = "attachment-file/" + storeAs +"/"+today+new Date().getTime()+ file.name;
|
|
storeAs = "attachment-file/" + storeAs +"/"+today+new Date().getTime()+ file.name;
|
|
- multitest(client, storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, cpt);
|
|
|
|
|
|
+ if(cpt == 1)
|
|
|
|
+ multitestFlag(client,storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, cpt,idx,prefix,currentUser);
|
|
|
|
+ else
|
|
|
|
+ multitest(client, storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, cpt);
|
|
})
|
|
})
|
|
};
|
|
};
|
|
|
|
|
|
function fBmultipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt,idx,prefix,currentUser) {
|
|
function fBmultipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt,idx,prefix,currentUser) {
|
|
|
|
+ console.log("-----------------------start");
|
|
|
|
+ console.log("-----------------------"+realPath);
|
|
|
|
+
|
|
file.name.replace(" ","")
|
|
file.name.replace(" ","")
|
|
file.name.replace(/—/g,"")
|
|
file.name.replace(/—/g,"")
|
|
var fileName = file.name;
|
|
var fileName = file.name;
|
|
@@ -149,12 +155,34 @@ function fBmultipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uplo
|
|
fileName = fileName.replace("……","")
|
|
fileName = fileName.replace("……","")
|
|
var dfl=new File([file],fileName,{type:file.type});
|
|
var dfl=new File([file],fileName,{type:file.type});
|
|
file = dfl
|
|
file = dfl
|
|
- /*console.log(file.name.indexOf("—")!=-1);
|
|
|
|
- console.log("-----------------------start");*/
|
|
|
|
- if(cpt == 1)
|
|
|
|
- fBmultitestFlag(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt,idx,prefix,currentUser);
|
|
|
|
- else
|
|
|
|
- multitest(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size, cpt,idx,prefix,currentUser);
|
|
|
|
|
|
+
|
|
|
|
+ requestUrl = realPath+"/previewController/getAccess";
|
|
|
|
+ OSS.urllib.request(requestUrl, {method: 'GET'}, function (err, response) {
|
|
|
|
+ if (err) {
|
|
|
|
+ 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;
|
|
|
|
+ if(cpt == 1)
|
|
|
|
+ fBmultitestFlag(client,storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, cpt,idx,prefix,currentUser);
|
|
|
|
+ else
|
|
|
|
+ multitest(client, storeAs, file,attachmentId,attachmentFlag,uploadPath.replace('http://dmtest-test.oss-cn-shanghai.aliyuncs.com', result.AliyunUrl),divId,size, cpt);
|
|
|
|
+ })
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -365,105 +393,106 @@ function fBmultitestFlag (storeAs, file,attachmentId,attachmentFlag,uploadPath,d
|
|
})
|
|
})
|
|
};
|
|
};
|
|
|
|
|
|
-function multitestFlag (storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,cpt,idx,prefix,currentUser) {
|
|
|
|
- var formdata = new FormData();
|
|
|
|
- formdata.append("storeAs",storeAs);
|
|
|
|
- formdata.append("file",file);
|
|
|
|
|
|
+function multitestFlag (ossClient,storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,cpt,idx,prefix,currentUser) {
|
|
var names = storeAs.split("/");
|
|
var names = storeAs.split("/");
|
|
var name = names[names.length-1];
|
|
var name = names[names.length-1];
|
|
- var fileLocation = "";
|
|
|
|
- var lookUrl = "";
|
|
|
|
- //获取文件存储位置(0:本地;1:百度云;2:阿里云)
|
|
|
|
- $.ajax({
|
|
|
|
- type:"get",
|
|
|
|
- url:realPath+"/bos/getFileStorageLocation",
|
|
|
|
- async: false,
|
|
|
|
- success:function(data){
|
|
|
|
- fileLocation = data.fileLocation;
|
|
|
|
|
|
+ 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+"%");
|
|
|
|
+ $("#fileName"+divId).html(file.name);
|
|
|
|
+ checkpoint_temp = cpt;
|
|
}
|
|
}
|
|
- });
|
|
|
|
- $.ajax({
|
|
|
|
- type:'post',
|
|
|
|
- url:realPath+"/bos/upload",
|
|
|
|
- data:formdata,
|
|
|
|
- contentType: false,
|
|
|
|
- processData: false,
|
|
|
|
- success:function (data1) {
|
|
|
|
- if(data1.code==='1'){
|
|
|
|
- returnUrl = realPath+"/sys/workattachment/saveAttachment";
|
|
|
|
- $.ajax({
|
|
|
|
- type:'post',
|
|
|
|
- url:returnUrl,
|
|
|
|
- data:{
|
|
|
|
- "attachmentName":file['name'],
|
|
|
|
- "attachmentId":attachmentId,
|
|
|
|
- "attachmentFlag":attachmentFlag,
|
|
|
|
- "url":data1.url,
|
|
|
|
- "divIdType":divId
|
|
|
|
- },
|
|
|
|
- success:function(data){
|
|
|
|
- var lowerType = data.type.toLowerCase();
|
|
|
|
- //console.log('url : ' + data.url);
|
|
|
|
- if(data.status=="Success"){
|
|
|
|
- parent.layer.msg("上传成功!",{icon:1});
|
|
|
|
- var str = '' ;
|
|
|
|
- var addFile = prefix+divId;
|
|
|
|
- if(2 == fileLocation){
|
|
|
|
- $.ajax({
|
|
|
|
- type:"post",
|
|
|
|
- async:false,
|
|
|
|
- url:realPath+"/workfullmanage/workFullManage/getFileTemporaryLookUrl",
|
|
|
|
- data:{"file":data.url,},
|
|
|
|
- success:function(result){
|
|
|
|
- lookUrl = result.lookUrl;
|
|
|
|
- if (isContains("jpg,png,gif,bmp,jpeg",lowerType)){
|
|
|
|
- str = str +'<img src="'+lookUrl+'" width="50" height="50" onclick="openDialogView(\'预览\',\''+ '/a/sys/picturepreview/picturePreview?url=' +lookUrl+ '\',\'90%\',\'90%\')" alt="'+data.attachmentName+'"/>';
|
|
|
|
- }else if(isContains("pdf",lowerType)){
|
|
|
|
- str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+lookUrl+'\',\'90%\',\'90%\',\'1\')">'+data.attachmentName+'</a>';
|
|
|
|
- }else {
|
|
|
|
- str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+lookUrl+'\',\'90%\',\'90%\')">'+data.attachmentName+'</a>';
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ }).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;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
- }else{
|
|
|
|
|
|
+ returnUrl = realPath+"/sys/workattachment/saveAttachment";
|
|
|
|
+ $.ajax({
|
|
|
|
+ type:'post',
|
|
|
|
+ url:returnUrl,
|
|
|
|
+ data:{
|
|
|
|
+ "attachmentName":file['name'],
|
|
|
|
+ "attachmentId":attachmentId,
|
|
|
|
+ "attachmentFlag":attachmentFlag,
|
|
|
|
+ "url":"/"+storeAs
|
|
|
|
+ },
|
|
|
|
+ success:function(data){
|
|
|
|
+ var lowerType = data.type.toLowerCase();
|
|
|
|
+ //console.log('url : ' + data.url);
|
|
|
|
+ if(data.status=="Success"){
|
|
|
|
+ parent.layer.msg("上传成功!",{icon:1});
|
|
|
|
+ var str = '' ;
|
|
|
|
+ var addFile = prefix+divId;
|
|
|
|
+ if(2 == fileLocation){
|
|
|
|
+ $.ajax({
|
|
|
|
+ type:"post",
|
|
|
|
+ async:false,
|
|
|
|
+ url:realPath+"/workfullmanage/workFullManage/getFileTemporaryLookUrl",
|
|
|
|
+ data:{"file":data.url,},
|
|
|
|
+ success:function(result){
|
|
|
|
+ lookUrl = result.lookUrl;
|
|
if (isContains("jpg,png,gif,bmp,jpeg",lowerType)){
|
|
if (isContains("jpg,png,gif,bmp,jpeg",lowerType)){
|
|
- str = str +'<img src="'+data.url+'" width="50" height="50" onclick="openDialogView(\'预览\',\''+ '/a/sys/picturepreview/picturePreview?url=' +data.url+ '\',\'90%\',\'90%\')" alt="'+data.attachmentName+'"/>';
|
|
|
|
|
|
+ str = str +'<img src="'+lookUrl+'" width="50" height="50" onclick="openDialogView(\'预览\',\''+ '/a/sys/picturepreview/picturePreview?url=' +lookUrl+ '\',\'90%\',\'90%\')" alt="'+data.attachmentName+'"/>';
|
|
}else if(isContains("pdf",lowerType)){
|
|
}else if(isContains("pdf",lowerType)){
|
|
- str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+data.url+'\',\'90%\',\'90%\',\'1\')">'+data.attachmentName+'</a>';
|
|
|
|
|
|
+ str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+lookUrl+'\',\'90%\',\'90%\',\'1\')">'+data.attachmentName+'</a>';
|
|
}else {
|
|
}else {
|
|
- str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+data.url+'\',\'90%\',\'90%\')">'+data.attachmentName+'</a>';
|
|
|
|
|
|
+ str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+lookUrl+'\',\'90%\',\'90%\')">'+data.attachmentName+'</a>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $(prefix+"_fileTypeDiv").empty();
|
|
|
|
- $(prefix+"_fileTypeDiv").append(str);
|
|
|
|
- $(prefix+"_uploadUserName").html(currentUser);
|
|
|
|
- var d = new Date();
|
|
|
|
- var dateTime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
|
|
|
|
- $(prefix+"_uploadDate").html(dateTime);
|
|
|
|
- $(prefix+"_fileName").val(data.attachmentName);
|
|
|
|
- $(prefix+"_fileType").val(data.type);
|
|
|
|
- $(prefix+"_fileUrl").val(data.url);
|
|
|
|
- $(prefix+"_fileAttachmentFlag").val(data.attachmentFlag);
|
|
|
|
- $(prefix+"_fileAttachmentId").val(data.attachmentId);
|
|
|
|
- var result = '<a style="margin-top: 10px;" 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>';
|
|
|
|
- var delResult =
|
|
|
|
- '<a href="javascript:void(0)" onclick="accordingBtn(this,\''+prefix+'\')" class=\"op-btn op-btn-edit" ><i class="fa fa-edit"></i> 修改</a>';
|
|
|
|
- $(prefix+"_operation").empty();
|
|
|
|
- $(prefix+"_operation").append(delResult);
|
|
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ if (isContains("jpg,png,gif,bmp,jpeg",lowerType)){
|
|
|
|
+ str = str +'<img src="'+data.url+'" width="50" height="50" onclick="openDialogView(\'预览\',\''+ '/a/sys/picturepreview/picturePreview?url=' +data.url+ '\',\'90%\',\'90%\')" alt="'+data.attachmentName+'"/>';
|
|
|
|
+ }else if(isContains("pdf",lowerType)){
|
|
|
|
+ str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+data.url+'\',\'90%\',\'90%\',\'1\')">'+data.attachmentName+'</a>';
|
|
}else {
|
|
}else {
|
|
- parent.layer.msg("上传失败!",{icon:2});
|
|
|
|
|
|
+ str = str + '<a class="attention-info" href="javascript:void(0)" onclick="preview(\'预览\',\''+data.url+'\',\'90%\',\'90%\')">'+data.attachmentName+'</a>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- })
|
|
|
|
- }else {
|
|
|
|
- parent.layer.msg("上传失败!",{icon:2});
|
|
|
|
|
|
+ $(prefix+"_fileTypeDiv").empty();
|
|
|
|
+ $(prefix+"_fileTypeDiv").append(str);
|
|
|
|
+ $(prefix+"_uploadUserName").html(currentUser);
|
|
|
|
+ var d = new Date();
|
|
|
|
+ var dateTime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
|
|
|
|
+ $(prefix+"_uploadDate").html(dateTime);
|
|
|
|
+ $(prefix+"_fileName").val(data.attachmentName);
|
|
|
|
+ $(prefix+"_fileType").val(data.type);
|
|
|
|
+ $(prefix+"_fileUrl").val(data.url);
|
|
|
|
+ $(prefix+"_fileAttachmentFlag").val(data.attachmentFlag);
|
|
|
|
+ $(prefix+"_fileAttachmentId").val(data.attachmentId);
|
|
|
|
+ var result = '<a style="margin-top: 10px;" 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>';
|
|
|
|
+ var delResult =
|
|
|
|
+ '<a href="javascript:void(0)" onclick="accordingBtn(this,\''+prefix+'\')" class=\"op-btn op-btn-edit" ><i class="fa fa-edit"></i> 修改</a>';
|
|
|
|
+ $(prefix+"_operation").empty();
|
|
|
|
+ $(prefix+"_operation").append(delResult);
|
|
|
|
+ }else {
|
|
|
|
+ parent.layer.msg("上传失败!",{icon:2});
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ })
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log("err------ err:");
|
|
|
|
+ console.log(err);
|
|
|
|
+ });
|
|
};
|
|
};
|
|
|
|
|
|
function multitest (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,cpt) {
|
|
function multitest (ossClient, storeAs, file,attachmentId,attachmentFlag,uploadPath,divId, size,cpt) {
|
|
|
|
+
|
|
var names = storeAs.split("/");
|
|
var names = storeAs.split("/");
|
|
var name = names[names.length-1];
|
|
var name = names[names.length-1];
|
|
ossClient.multipartUpload(storeAs, file,{
|
|
ossClient.multipartUpload(storeAs, file,{
|