TripleSpeederT
Convex Communityβ€’2y agoβ€’
10 replies
TripleSpeeder

Error testing file upload

This is probably something stupid on my side... But maybe someone can help πŸ™‚
I'm testing image upload with convex-test. For simplicity i just create a 100 Byte Blob like this:
const image = new Blob([new ArrayBuffer(100)]);
// Store the image in Convex
const storageId = await t.run(async (ctx) => {
   return ctx.storage.store(image);
});

However this throws the following error inside store function:
TypeError: blob.arrayBuffer is not a function
    at blobSha (/home/michael/dev/prototest/node_modules/convex-test/dist/index.js:833:36)


When I use the blob from a real image it works as expected:
const imageUrl = "https://fakeimg.pl/800x600/";
const response = await fetch(imageUrl);
const image = await response.blob();
// Store the image in Convex
const storageId = await t.run(async (ctx) => {
   return ctx.storage.store(image);
});


Any idea what I'm doing wrong when creating the Blob data?
Was this page helpful?