|
|
|
@ -6,7 +6,7 @@ import { HttpClient,HttpHeaders } from '@angular/common/http';
|
|
|
|
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
|
|
|
|
import { IsLoginService } from '../../is-login.service' |
|
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
|
|
|
import { async } from '@angular/core/testing'; |
|
|
|
|
import {UploadFilesComponent} from '../upload-files/upload-files.component' |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-all-file', |
|
|
|
|
templateUrl: './all-file.component.html', |
|
|
|
@ -31,6 +31,7 @@ export class AllFileComponent {
|
|
|
|
|
|
|
|
|
|
selection = new SelectionModel(true, []); |
|
|
|
|
@ViewChild(MatSort) sort: MatSort; |
|
|
|
|
@ViewChild( 'child',{static: false} ) child:UploadFilesComponent //上传文件夹子组件
|
|
|
|
|
|
|
|
|
|
oldDataSource:any; //原始表格数据
|
|
|
|
|
//表头排序
|
|
|
|
@ -348,6 +349,8 @@ export class AllFileComponent {
|
|
|
|
|
//上传文件夹
|
|
|
|
|
async selectFiles (e) { |
|
|
|
|
this.fileArr = e.target.files || null //上传的文件
|
|
|
|
|
this.uploadisLoading2 = true |
|
|
|
|
this.child.handleData() //子组件处理数据格式
|
|
|
|
|
let _this = this |
|
|
|
|
for (var i = 0;i < this.fileArr.length; i++) { |
|
|
|
|
let f = this.fileArr[i]; |
|
|
|
@ -359,8 +362,8 @@ export class AllFileComponent {
|
|
|
|
|
let result = await new Promise ((result,reject)=>{ |
|
|
|
|
this.startUploading2(f,adddress,result,reject,filesnum,this.selectedDataBank) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//上传文件
|
|
|
|
@ -375,24 +378,29 @@ export class AllFileComponent {
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
|
this.uploadisLoading2 = true |
|
|
|
|
this.uploadProgress2 = 0 + "/" + filesnum |
|
|
|
|
// this.uploadProgress2 = 0 + "/" + filesnum
|
|
|
|
|
this.child.uploading(file) //子组件 当前文件正在上传
|
|
|
|
|
|
|
|
|
|
if (file && fileSize<=shardSize) { //上传文件<=5MB时
|
|
|
|
|
// console.log(selectedDataBank)
|
|
|
|
|
|
|
|
|
|
let formData = new FormData() |
|
|
|
|
formData.append("file",file) |
|
|
|
|
this.http.post(`/api/Objects/drives/${selectedDataBank2}`,formData).subscribe((data:any)=>{ |
|
|
|
|
this.objectName2 = data.objectName |
|
|
|
|
this.filesTag2.push("data") |
|
|
|
|
this.zone.run(() => { |
|
|
|
|
setTimeout(() => this.uploadProgress2 = this.filesTag2.length + "/" + filesnum, 0); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// this.zone.run(() => {
|
|
|
|
|
// setTimeout(() => this.uploadProgress2 = this.filesTag2.length + "/" + filesnum, 0);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
result("成功了") |
|
|
|
|
this.child.endUpload(file) //子组件 当前文件上传成功
|
|
|
|
|
|
|
|
|
|
if(this.filesTag2.length == filesnum){ |
|
|
|
|
this.filesTag2 = [] //清空计数文件夹
|
|
|
|
|
this.uploadProgress2 = filesnum + "/" + filesnum |
|
|
|
|
this.uploadisLoading2 = false |
|
|
|
|
this.child.delete() //清空上传文件夹子组件数据
|
|
|
|
|
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
@ -441,25 +449,26 @@ export class AllFileComponent {
|
|
|
|
|
}); |
|
|
|
|
this.PartNumberETag2.push(result) |
|
|
|
|
if (this.PartNumberETag2.length === allSlice) { |
|
|
|
|
this.endUploading2(_result,reject,filesnum,selectedDataBank2)} |
|
|
|
|
this.endUploading2(e,_result,reject,filesnum,selectedDataBank2)} |
|
|
|
|
}//for循环
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//完成分块上传
|
|
|
|
|
endUploading2 (result,reject,filesnum,selectedDataBank2) { |
|
|
|
|
endUploading2 (e,result,reject,filesnum,selectedDataBank2) { |
|
|
|
|
let data = this.PartNumberETag2 |
|
|
|
|
let paramsData = {uploadId:this.uploadId2} |
|
|
|
|
|
|
|
|
|
this.http.post(`/api/CompleteMultipartUpload/drives/${this.objectName2}`,data,{params:paramsData}).subscribe(data=>{ |
|
|
|
|
|
|
|
|
|
this.filesTag2.push("data") |
|
|
|
|
this.zone.run(() => { |
|
|
|
|
setTimeout(() => this.uploadProgress2 = this.filesTag2.length + "/" + filesnum, 0); |
|
|
|
|
}); |
|
|
|
|
// this.zone.run(() => {
|
|
|
|
|
// setTimeout(() => this.uploadProgress2 = this.filesTag2.length + "/" + filesnum, 0);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result("成功了") |
|
|
|
|
this.child.endUpload(e) //子组件 当前文件上传成功
|
|
|
|
|
|
|
|
|
|
if(this.filesTag2.length == filesnum){ |
|
|
|
|
|
|
|
|
@ -467,6 +476,7 @@ export class AllFileComponent {
|
|
|
|
|
this.uploadisLoading2 = false |
|
|
|
|
|
|
|
|
|
this.filesTag2 = [] //清空计数文件夹
|
|
|
|
|
this.child.delete() //清空上传文件夹子组件数据
|
|
|
|
|
this.getALLFileList(selectedDataBank2) |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
@ -482,7 +492,11 @@ export class AllFileComponent {
|
|
|
|
|
cancel2 () { |
|
|
|
|
this.http.delete(`/api/MultipartUpload/drives/${this.objectName2}?uploadId=${this.uploadId2}`).subscribe(data=>{ |
|
|
|
|
this.uploadisLoading2= false |
|
|
|
|
this.fileArr = {} |
|
|
|
|
this.PartNumberETag2 =[] //清空保存返回的信息
|
|
|
|
|
this.filesTag2 = [] //清空计数文件夹
|
|
|
|
|
this.child.delete() //清空上传文件夹子组件数据
|
|
|
|
|
this.getALLFileList(this.selectedDataBank) |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|