Handling files returned by API

Hi @Nick_HE - Working with binary content has proven to be a bit tricky in my experience. Two options I think would work:

  1. If that Accept header isn’t required then you can use the simpler storeUrl method instead, as shown in the “Private Images” section of that same page. It basically bundles up the fetch and store into one operation.
  2. If you do need to set that header, than make sure to set isBinaryResponse: true on your fetch request, as shown here. This will cause response.body to be a Buffer, which is exactly what you need for storeBlob.
2 Likes