|
|
|
@ -64,7 +64,8 @@ export class AllFileComponent {
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.dataSource.sort = this.sort; |
|
|
|
|
this.getAllDataBank() |
|
|
|
|
// this.getAllDataBank()
|
|
|
|
|
this.getALLFileList("支队级-主官") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获得所有资料库,默认显示第一个资料库的文件
|
|
|
|
@ -374,8 +375,6 @@ export class AllFileComponent {
|
|
|
|
|
fileArr:any |
|
|
|
|
//上传文件夹
|
|
|
|
|
async selectFiles (e) { |
|
|
|
|
|
|
|
|
|
// console.log(e)
|
|
|
|
|
|
|
|
|
|
this.fileArr = e.target.files || null //上传的文件
|
|
|
|
|
this.uploadisLoading2 = true |
|
|
|
@ -462,26 +461,26 @@ export class AllFileComponent {
|
|
|
|
|
let allSlice = Math.ceil(fileSize / shardSize) //总文件/5MB===共分多少段
|
|
|
|
|
let _result = result |
|
|
|
|
for (let i = 0;i < allSlice;i++) { //循环分段上传
|
|
|
|
|
let start = i * shardSize //切割文件开始位置
|
|
|
|
|
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置
|
|
|
|
|
let formData = new FormData() |
|
|
|
|
formData.append("file",file.slice(start, end)) |
|
|
|
|
|
|
|
|
|
//同步写法实现异步调用
|
|
|
|
|
let result = await new Promise((resolve, reject) => { |
|
|
|
|
// await 需要后面返回一个 promise 对象
|
|
|
|
|
this.http.post(`/api/MultipartUpload/drives/${this.objectName2}?uploadId=${this.uploadId2}&partNumber=${i+1}`,formData).subscribe((data:any)=>{ |
|
|
|
|
let msg = { |
|
|
|
|
"partNumber":data.partNumber || null, |
|
|
|
|
"eTag": data.eTag || null} |
|
|
|
|
resolve(msg) // 调用 promise 内置方法处理成功
|
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
this.PartNumberETag2.push(result) |
|
|
|
|
if (this.PartNumberETag2.length === allSlice) { |
|
|
|
|
this.endUploading2(e,_result,reject,filesnum,selectedDataBank2)} |
|
|
|
|
let start = i * shardSize //切割文件开始位置
|
|
|
|
|
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置
|
|
|
|
|
let formData = new FormData() |
|
|
|
|
formData.append("file",file.slice(start, end)) |
|
|
|
|
|
|
|
|
|
//同步写法实现异步调用
|
|
|
|
|
let result = await new Promise((resolve, reject) => { |
|
|
|
|
// await 需要后面返回一个 promise 对象
|
|
|
|
|
this.http.post(`/api/MultipartUpload/drives/${this.objectName2}?uploadId=${this.uploadId2}&partNumber=${i+1}`,formData).subscribe((data:any)=>{ |
|
|
|
|
let msg = { |
|
|
|
|
"partNumber":data.partNumber || null, |
|
|
|
|
"eTag": data.eTag || null} |
|
|
|
|
resolve(msg) // 调用 promise 内置方法处理成功
|
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
this.PartNumberETag2.push(result) |
|
|
|
|
if (this.PartNumberETag2.length === allSlice) { |
|
|
|
|
this.endUploading2(e,_result,reject,filesnum,selectedDataBank2) |
|
|
|
|
} |
|
|
|
|
}//for循环
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//完成分块上传
|
|
|
|
@ -493,10 +492,9 @@ export class AllFileComponent {
|
|
|
|
|
|
|
|
|
|
this.filesTag2.push("data") |
|
|
|
|
this.zone.run(() => { |
|
|
|
|
setTimeout(() => this.uploadProgress2 = this.filesTag2.length + "/" + filesnum, 0); |
|
|
|
|
setTimeout(() => this.uploadProgress2 = this.filesTag2.length + "/" + filesnum, 0); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result("成功了") |
|
|
|
|
this.child.endUpload(e) //子组件 当前文件上传成功
|
|
|
|
|
|
|
|
|
@ -816,7 +814,7 @@ export class AllFileComponent {
|
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('文件夹不支持下载','确定',config) |
|
|
|
|
}else{ |
|
|
|
|
this.http.get('/api/ObjectMetadata/drives/allFiles/' + this.selectDownloadFile.key).subscribe(data=>{ |
|
|
|
|
this.http.get('/api/ObjectMetadata/drives/' + this.selectDownloadFile.key).subscribe(data=>{ |
|
|
|
|
console.log(123,data) |
|
|
|
|
this.download = data |
|
|
|
|
this.downloadFile.download(this.download) |
|
|
|
|