gsutil zip directory on google cloud storage
Asked Answered
S

3

6

is it possible to compress file or directory of google cloud storage without download it first and re-upload?

I think I need some tools similar like http://googlegenomics.readthedocs.org/en/latest/use_cases/compress_or_decompress_many_files/

thank you.

Speller answered 23/1, 2016 at 18:57 Comment(0)
N
14

No. There is no way to ask GCS to directly compress or decompress objects entirely within GCS. You can certainly copy them elsewhere in the cloud (GCE, for instance) and operate on them there, or you could download an uncompressed object as a compressed object simply by using the Accept-Encoding: gzip header, but, again, not without taking it out of GCS in some fashion.

Negotiant answered 24/1, 2016 at 6:42 Comment(0)
E
8

From

https://console.cloud.google.com/storage/browser/your-bucket

open a cloud shell (top right of the page), then:

gsutil cp -r gs://your-bucket .
zip your-bucket.zip ./your-bucket
gsutil cp your-bucket.zip gs://your-bucket

Strictly it is not happening in place within your storage but within the cloud.

Eliseoelish answered 30/10, 2020 at 10:47 Comment(1)
"zip -r your-bucket.zip ./your-bucket" -r to zip all the files recursivelyBatavia
E
0

To limit Harps' solution to some "directory", i.e., to get a directory.zip containing all files with that prefix:

open a cloud shell (top right of the page), then:

gsutil cp -r gs://your-bucket/directory .
zip directory.zip ./directory/*
gsutil cp directory.zip gs://your-bucket

Keep in mind this method also copies these files out to the local file system on your Google Cloud Shell machine.

Emmott answered 18/4, 2024 at 21:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.