|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Author: sueRimn |
|
|
|
|
* @Date: 2020-11-05 15:27:58 |
|
|
|
|
* @LastEditors: sueRimn |
|
|
|
|
* @LastEditTime: 2020-11-06 14:10:39 |
|
|
|
|
* @LastEditTime: 2020-11-06 16:36:48 |
|
|
|
|
*/ |
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http'; |
|
|
|
@ -64,6 +64,29 @@ export class KnowRouteComponent implements OnInit {
|
|
|
|
|
uploadId: any; //上传分块上传事件编号
|
|
|
|
|
isspinner:boolean=false //控制进度圈的显示隐藏
|
|
|
|
|
PartNumberETag: any = []; //分块上传每次返回需要保存的信息
|
|
|
|
|
//change选择文件
|
|
|
|
|
filechange(e) { |
|
|
|
|
this.file = e.target.files[0] || null //上传的文件
|
|
|
|
|
var reader = new FileReader(); |
|
|
|
|
reader.readAsDataURL(this.file); |
|
|
|
|
var image:any = new Image(); |
|
|
|
|
reader.onload = function(){ |
|
|
|
|
image.src = reader.result |
|
|
|
|
} |
|
|
|
|
setTimeout(() => { |
|
|
|
|
if(image.width>=4096 || image.height>=5000 ){
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('请选择分辨率小于4096*5000的图片','确定',config); |
|
|
|
|
}else{ |
|
|
|
|
if(this.file){ |
|
|
|
|
this.startUploading() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, 500); |
|
|
|
|
}
|
|
|
|
|
//上传文件
|
|
|
|
|
startUploading() { |
|
|
|
|
this.isspinner = true |
|
|
|
@ -86,12 +109,12 @@ export class KnowRouteComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
} else if (file && fileSize >= shardSize) { //上传文件>5MB时,分块上传
|
|
|
|
|
|
|
|
|
|
let data = { filename: file.name } |
|
|
|
|
/* let data = { filename: file.name } |
|
|
|
|
this.http.post(`/api/NewMultipartUpload/PlanPlatform/${this.unitinfo.id}`, {}, { params: data }).subscribe((data: any) => { //初始化分段上传
|
|
|
|
|
this.objectName = data.objectName |
|
|
|
|
this.uploadId = data.uploadId |
|
|
|
|
this.subsectionUploading() |
|
|
|
|
}) |
|
|
|
|
}) */ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//开始分块上传
|
|
|
|
|