0

I have a requirement to convert byte[] to Multipart using Angular 10. How can I do this?

In receiving email I get the image as byte[] I want to convert this to Multipart file and send. How can I achieve this?

Thanks!

1 Answers1

1
// Assuming you have a byte[] called myBytes
const myBlob = new Blob([myBytes]);
const formData = new FormData();
formData.append('file', myBlob, 'filename.bin');

const req = new HttpRequest('POST', ' upload url ', formData, {
  reportProgress: true
});

// You can then use the HttpClient to send the request
this.http.request(req).subscribe(event => {
  // Handle response
});
Moufeed Juboqji
  • 690
  • 4
  • 11