GoogleCloudPlatform / GoogleCloudPlatform/gsutil

how to `gsutil cp` gzip files without decompressing them?

Open
#515 9 comments 1 reaction 0 assignees View on GitHub
Feature Request
Dominant language
Python
Stars
918
Forks
335
PR merge metrics
No merged PRs in 30d

Description

Reading GCS [decompressive transcoding](https://cloud.google.com/storage/docs/transcoding#decompressive_transcoding) documentation, I understand that the only way to retrieve a gziped file stored on GCS with `Content-Encoding: gzip` in its compressed state is to pass `"Accept-Encoding: gzip"` header when requesting it.

When trying to do so using `gsutil`, I have an error:

```
$ gsutil ls -L gs://xxx/0.json.gz | grep 'Content-'
Content-Encoding: gzip
Content-Length: 129793
Content-Type: text/plain
$ gsutil -h "Accept-Encoding: gzip" cp gs://xxx/0.json.gz .
ArgumentException: Invalid header specified: accept-encoding: gzip
```

(I know this example is probably bad; the extension shouldn't be explicitely set to `.gz` but I have to work with this right now)

My guess is that `gsutil` performs client-side decompression (as suggested by [`gsutil cp`](https://cloud.google.com/storage/docs/gsutil/commands/cp#changing-temp-directories) documentation) and so it prevents from passing the `Accept-Encoding` header.

My question is then how can I use `gsutil` to download a gzip file that has his metadata set to `Content-Encoding: gzip` without decompressing it (and *without* having to set other metadata like `Cache-control: no-transform` if that would be a workaround)?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.