gpt4 book ai didi

angular ng2-file-upload 获取上传的文件 block

转载 作者:行者123 更新时间:2023-12-03 21:00:45 27 4
gpt4 key购买 nike

我正在使用 ng2-file-upload 来上传任何类型的图像和文件,常规示例工作正常,但我实际上想检索上传的文件的 blob 并且不使用常规处理,因为我要去在服务器端做我自己的处理。
任何人都可以告诉如何在选择后上传文件的blob?

我想做的是这样的:

this.uploader.onAfterAddingFile = fileItem => {
fileItem.withCredentials = false;
this.file
.uploadAttachment(fileItem)
.pipe()
.subscribe(data => {
console.log(data);
});
};

最佳答案

就我而言,我已经解决了检索 的问题。文件 来自 的对象文件项 .

let file = fileItem.file;
const blob = new Blob([file.rawFile], { type: file.type });
this.file
.uploadAttachment(blob)
.pipe()
.subscribe(data => {
console.log(data);
});

关于angular ng2-file-upload 获取上传的文件 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57922265/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com