Repository navigation
Is gzip uploading possible through the API #751
Description
Activity
we have to gzip the files ourselves and then upload it with gzip meta data?
Yes. It would look something like:
var fs = require('fs'); var zlib = require('zlib'); var file = bucket.file('file.gz'); var writeStream = file.createWriteStream({ metadata: { contentEncoding: 'gzip' } }); fs.createReadStream('./file') .pipe(zlib.createGzip()) .pipe(writeStream);
Using the stream implementation, it's easy to attach a GCS writable stream to any data manipulation pipeline. However, it wouldn't be a big task to support this more easily in our library. I'll let others chime in.
Thanks for the question!
- addedapi: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.
on Jul 28, 2015 Thanks stephenplusplus, that makes sense to me. I'll go ahead and close the issue. Might not be worthwhile as a feature, but perhaps a mention in the docs? Just an afterthought though :)
How common is gzipping ? If it's something people often want to do, is there a way we could simplify this ? So that it's much less code?
Ideally, uploading a .gz version of a file would be the same number of lines (with an extra config or different method call) as uploading the uncompressed version.
It's probably common enough to make it easier. I'll send a PR.
- added a commit that references this issue
on Nov 10, 2022 - added a commit that references this issue
on Nov 19, 2022 - added a commit that references this issue
on Dec 5, 2022 - added a commit that references this issue
on Dec 16, 2022 - added a commit that references this issue
on Jul 23, 2025 6 remaining items
- added a commit that references this issue
on Jan 28, 2026 - added a commit that references this issue
on Jan 28, 2026 - added 4 commits that reference this issue
on Jan 29, 2026 - added a commit that references this issue
on Feb 17, 2026 - added a commit that references this issue
on Feb 25, 2026 - added a commit that references this issue
on Mar 18, 2026 - added 2 commits that reference this issue
on Mar 23, 2026 - added a commit that references this issue
on Mar 27, 2026 - added a commit that references this issue
on May 5, 2026
Hi guys
I have been reading the documentation and from what I understand there is functionality to gzip uploaded files to storage - or at least the functionality exists through the gsutil.
"Note also that gsutil provides an easy way to cause content to be compressed and stored with Content-Encoding: gzip: see the -z option"
Is this currently possible through the node API? I have not seen it mentioned in the docs or code comments. If not, does this mean we have to gzip the files ourselves and then upload it with gzip meta data?