Reputation: 63
What would be the most efficient way to handle unzipping of a file and storing then uploading the unzipped file to Supabase? There is no server-side available for SupaBase, so should I host an API elswhere that takes care of the unzipping part and eventually uploads the extracted file to SupaBase?
Upvotes: 0
Views: 358
Reputation: 7024
For small files, you can create an Edge Function that uses a decompression stream:
const src = await Deno.open("./testdata/singleFile.txt.gz");
const dest = await Deno.open("./testdata/singleFile.txt", {
create: true,
write: true,
});
src.readable
.pipeThrough(new DecompressionStream("gzip"))
.pipeTo(dest.writable);
Then you can use this stream to pass the object to Supabase by tweaking this upload to storage example to take this decompression stream.
For large files, then it would probably be a better idea to create a server to extract and then upload it to Supabase Storage after the extraction was completed.
Upvotes: 1