Skip to content

Support for setting the Content-Encoding header when uploading files to Storage #1883

@miwelc

Description

@miwelc

Description

I've searched in the documentation but I haven't found a way to set the Content-Encoding header when uploading files to Storage.
In our use case, we are storing in Supabase Storage big files that would compress nicely with gzip (compressed files are just ~10% of uncompressed size).
We upload these files from an Edge function and consume them in the browser.
If we could set the Content-Encoding we could save bandwidth and storage space by storing them compressed and then letting the browser ungzip the file when fetching it.

Suggested solution

const file = await Deno.open(localPath, { read: true });
const compressedStream = file.readable.pipeThrough(new CompressionStream('gzip'));
await supabase.storage
	.from('my_bucket')
	.upload(remotePath, compressedStream, {
		contentType: 'application/octet-stream',
		contentEncoding: 'gzip'
	});

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions