2

I have an api that expects to receive an image with "application/octet-stream", I currently have a "ng2-file-upload" library, I would like to make it work with it but if it is not possible I could try with another one or just Even angular.

Currently my code looks like this:

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;
    };
}

With postman I can upload with the following settings: enter image description here

enter image description here

maistack123
  • 135
  • 10

0 Answers0