Bug: Netlify Blobs lose their types

Using Netlify Blobs in my Edge function I do this:

const pictures = getStore("pictures");
const pictureBlob = new Blob([pictureArrayBuffer], { type: "image/png" });
await pictures.set(someUuid, pictureBlob);

And pictureBlob has the MIME type of “image/png” as I’m setting it in my store (as shown in VS Code’s debugger below)

But when I retrieve it later using the below code, it has lost its type:

const pictures = getStore("pictures");
let picture = await pictures.get(someUuid, { type: "blob" });
picture = URL.createObjectURL(picture.data);

I wonder if this lack of Blob type, when used with URL.createObjectURL is the reason why the Blob URLs aren’t working in my application, they look like this

blob:null/d3b9c550-4337-4cc5-857d-37800

Notice the “null”.

I have checked this several times: the Blobs being stored have a type, but when retrieved they’ve lost it and my Blob URLs don’t work. Thus I think it must be a bug.

Thanks for your time

URL.createObjectURL() is mostly useful in client-side JavaScript. Based on your code, I assume your goal is to serve the image from an Edge Function. If so, you can simply do:

return new Response(picture)

Thanks for your response. I fetch the image in the Edge function and do some other logic before returning the Response. I can use Base64, but prefer Blob URLs because Base64 encoding increases the image size by about 33%. Are Netlify Edge functions unable to create working image URLs when using URL.createObjectURL on stored image blobs within Netlify Blobs?

As I mentioned, URL.createObjectURL is useful in client-side environments, not server-side. It’s not Netlify Edge Functions or Blobs that are unable to create the URL, it’s more to do with that URL would be useless. The blob needs to exist on the client for it to show the data. Simply returning a URL pointing to a Blob on the server won’t allow the client to show it.

Not sure why that would make a difference. As long as your image exists as an ArrayBuffer or a Blob, you should still be able to return it as it is to the client.