我有一个希望接收带有“application/octet-stream”的图像的 api,我目前有一个“ng2-file-upload”库,我想让它与它一起工作,但如果不可能,我可以尝试与另一个或只是偶数角。
目前我的代码如下所示:
constructor(
) {
const bearer = 'Bearer ' + this.authService.getToken();
this.uploadImageNewsletter = new FileUploader({
url: `https://myapi/upload?extension=jpg`,
autoUpload: true,
method: 'post',
isHTML5: true,
allowedMimeType: ['application/octet-stream', 'image/png', 'image/jpg', 'image/jpeg', 'image/gif'],
allowedFileType: ['application/octet-stream', 'image', 'pdf'],
// disableMultipart: false,
headers: [
{
name: 'Authorization',
value: bearer
},
{
name: 'Content-Type',
value: 'application/octet-stream'
}
]
});
this.uploadImageNewsletter.onProgressAll = () => {
this.loading = true;
};
this.uploadImageNewsletter.onCompleteItem = (item: FileItem) => {
item.remove();
this.loading = false;
};
}