|
|
|
@ -82,8 +82,11 @@ export class IsLoginService {
|
|
|
|
|
uploadisLoading:boolean = false //上传进度条显示
|
|
|
|
|
uploadProgress:any = 0 |
|
|
|
|
uploadId:any; //上传分块上传事件编号
|
|
|
|
|
|
|
|
|
|
filesTag:any //每上传成功一个文件就往里面加一个标识
|
|
|
|
|
|
|
|
|
|
//e是上传的文件 selectedDataBank是需要上传的地址 包括 XXX资料库 + 文件夹路径
|
|
|
|
|
startUploading (e,selectedDataBank) { |
|
|
|
|
startUploading (e,selectedDataBank,result,reject,filesnum) { |
|
|
|
|
let file = e || null //获取上传的文件
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
@ -94,7 +97,13 @@ export class IsLoginService {
|
|
|
|
|
// console.log(666,file)
|
|
|
|
|
this.http.post(`/api/Objects/drives/${selectedDataBank}`,formData).subscribe((data:any)=>{ |
|
|
|
|
this.objectName = data.objectName |
|
|
|
|
console.log(666,data) |
|
|
|
|
|
|
|
|
|
result(data) |
|
|
|
|
this.filesTag.push(data) |
|
|
|
|
if(this.filesTag.length == filesnum){ |
|
|
|
|
alert("文件夹全部上传完毕") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//当全部循环完毕重新加载列表
|
|
|
|
|
// this.getALLFileList(this.selectedDataBank)
|
|
|
|
|
}) |
|
|
|
@ -104,7 +113,7 @@ export class IsLoginService {
|
|
|
|
|
this.http.post(`/api/NewMultipartUpload/drives/${selectedDataBank}`,{},{params:data}).subscribe((data:any)=>{ //初始化分段上传
|
|
|
|
|
this.objectName = data.objectName |
|
|
|
|
this.uploadId = data.uploadId |
|
|
|
|
this.subsectionUploading(e) |
|
|
|
|
this.subsectionUploading(e,result,reject,filesnum) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -112,7 +121,7 @@ export class IsLoginService {
|
|
|
|
|
|
|
|
|
|
PartNumberETag:any=[]; //每次返回需要保存的信息
|
|
|
|
|
//开始分段上传
|
|
|
|
|
async subsectionUploading (e) { |
|
|
|
|
async subsectionUploading (e,result,reject,filesnum) { |
|
|
|
|
let file = e || null //获取上传的文件
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
@ -139,18 +148,23 @@ export class IsLoginService {
|
|
|
|
|
|
|
|
|
|
if (this.PartNumberETag.length === allSlice) { |
|
|
|
|
this.uploadProgress = 100 |
|
|
|
|
this.endUploading()} |
|
|
|
|
this.endUploading(result,reject,filesnum)} |
|
|
|
|
}//for循环
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//完成分块上传
|
|
|
|
|
endUploading () { |
|
|
|
|
endUploading (result,reject,filesnum) { |
|
|
|
|
let data = this.PartNumberETag |
|
|
|
|
let paramsData = {uploadId:this.uploadId} |
|
|
|
|
|
|
|
|
|
this.http.post(`/api/CompleteMultipartUpload/drives/${this.objectName}`,data,{params:paramsData}).subscribe(data=>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result(data) |
|
|
|
|
this.filesTag.push(data) |
|
|
|
|
if(this.filesTag.length == filesnum){ |
|
|
|
|
alert("文件夹全部上传完毕") |
|
|
|
|
} |
|
|
|
|
//当全部循环完毕重新加载列表
|
|
|
|
|
// this.getALLFileList(this.selectedDataBank)
|
|
|
|
|
this.uploadProgress = 0; |
|
|
|
|