0

I'm working with an API for uploading a user image, the uploading process is quite simple, just choose the file from the user's device and send it as it is in a FormData (File, Binary).

But, when it comes for downloading this file from the storage, the response is really wired for me and containing some characters that because of it I can't indicate if that is a problem from the back-end handling or it's an invalid file or it's a regular formula that I didn't deal with it before.

my question is what should this data represent? And how to convert it to a file that a user can download?

here is a screenshot of it. here

Mohamed
  • 1
  • 1
  • 2
    can you show your code? – jhon Jul 08 '20 at 14:19
  • ok, and what language did you use to get data from backend? – jhon Jul 08 '20 at 14:21
  • I would love that, it would help me a lot in debugging but, I don't have the back-end code. and the screenshot is just the response of the api – Mohamed Jul 08 '20 at 14:21
  • I don't know how to help you because you don't give information like language or etc. But now I assume you use postman to call API. according to screenshot that you give, I only can tell you, response have raw response with type `IHDR` and backend give response `JSON` type. – jhon Jul 08 '20 at 14:32
  • This is what an PNG is going to look like when you display the file's contents as text – tshimkus Jul 08 '20 at 21:25

1 Answers1

0

After struggling with many cases, the problem was that I didn't define the content-type within the request headers

headers: {
'Content-Type': 'blob'
}

notice that this type of data is a regular Blob file.

Mohamed
  • 1
  • 1