2

I do upload a zipped file to Google Storage Bucket. The file is huge so I do not want to upload it in uncompressed format. I am trying to find out if I can unzip this file directly in google bucket.

I read about cloud functions and using that to unzip any file uploaded. But I would prefer having control on the file to be unzipped via Java Code. Has anyone tried this before?

Thanks in Advance!

Nikita Kotak
  • 113
  • 3
  • 10
  • If I understand correctly, you would like to unzip the file directly in GCS. You wouldn't like to use Cloud Functions because in that way, you will download the file, unzip and then upload it again. Can you confirm that? – ericcco Sep 30 '19 at 13:02
  • @eespinola Yes I want to unzip the file directly in GCS – Nikita Kotak Oct 03 '19 at 06:23
  • GCS does not perform processing on files, it stores them. If you need to process (unzip) the file, that work has to be done somewhere else: in a Cloud Function, a VM, etc. – Travis Webb Oct 03 '19 at 20:33

2 Answers2

1

You can gzip-compress the file when uploading to Google Cloud Storage so that whenever the file is downloaded, it is automatically decompressed before being sent back, see this documentation for more information.

JKleinne
  • 1,270
  • 7
  • 14
  • Thanks JKleinne, I'll try gzip-compress – Nikita Kotak Oct 03 '19 at 06:24
  • For gzip-compression technique the content-type should be plain text as mentioned in documentation, in my scenario I have various types of files in that zip. – Nikita Kotak Oct 03 '19 at 09:49
  • The content-type set to plain text was just an example and so any of these [content-type](https://stackoverflow.com/questions/23714383/what-are-all-the-possible-values-for-http-content-type-header) should work. What Travis Webb said is correct, file processing can only be done elsewhere. Because `gzip` functions as a compressing algorithm **only**, it cannot `zip` using the `gzip` command, although you can run `tar -zcvf compressed.tar.gz folder` which will use `tar` to archive data and which then can be compressed using gzip. – JKleinne Oct 06 '19 at 13:36
0

Found an answer here : How do I unzip a .zip file in google cloud storage?

Dataflow API can be used for this purpose to decompress the file.

Nikita Kotak
  • 113
  • 3
  • 10