【发布时间】:2020-01-15 05:59:19
【问题描述】:
我正在使用 ng2-file-upload 来上传任何类型的图像和文件,常规示例工作正常,但我实际上想检索上传文件的 blob 而不是使用常规处理,因为我'我要在服务器端做我自己的处理。 谁能告诉我选择后如何上传文件的blob?
我想做的是这样的:
this.uploader.onAfterAddingFile = fileItem => {
fileItem.withCredentials = false;
this.file
.uploadAttachment(fileItem)
.pipe()
.subscribe(data => {
console.log(data);
});
};
【问题讨论】:
-
从这个answer,我猜blob可以像这样创建:
const blob = new Blob([this.file], { type: 'application/pdf' });