0
votes

I am trying to deflate a 7z multipart container within a Google Cloud Storage Bucket. Can I do this without copying the data locally and re-uploading?

I want to make sure that I perform the extraction of the files without generating unnecessary overhead. I am not sure if there is any way this can be done directly within the Bucket.

In an ideal scenario I could decompress the archives directly into the Bucket.

1

1 Answers

0
votes

I believe you might be making confusion between the term storage that one would be used to nowadays, as in a persistent disk accessed by a File System abstraction, and what you can do with a Google Cloud Storage Bucket.

You can make several operations on Objects, which are the pieces of data that reside in Buckets, including upload and download.

So, you have a compressed file in a Bucket and you want to decompress it and have the decompressed content in a Bucket too. Then you have to download the compressed file to some machine that is able to decompress it and after that you’d upload the decompressed content.

I'll leave you here a demonstration:

Make sure you have an archive file and nothing else on the current directory.

ARCHIVE=ar0000.7z

Create a Bucket, if you don't got one created already:

gsutil mb gs://sevenzipblobber

Upload the archive file to a Bucket:

gsutil cp -v $ARCHIVE gs://sevenzipblobber/archives/

Download the archive file from a Bucket (this could from any other Bucket at any other time):

gsutil cp -v gs://sevenzipblobber/archives/$ARCHIVE .

Extract and remove the archive:

7z x $ARCHIVE && rm -v $ARCHIVE

Upload to a Bucket the contents of the current directory, which should be the contents of the archive file decompressed (keep in mind that with the -m flag, that speeds up the upload, the output will be jumbled up).

gsutil -m cp -vr . gs://sevenzipblobber/dearchives/$ARCHIVE

List the contents of the Bucket:

gsutil ls -r gs://sevenzipblobber/

You could also use a Client Server pattern, where the Server would be responsable for decompressing the archive and upload the contents to Cloud Storage again.

The Client could be Google Cloud Functions triggered by an event on a Bucket, in this case the Server could be an HTTP Server waiting for the upload. Or the Client could be Cloud Pub/Sub Notifications for Cloud Storage and therefore Server would have to be subscribed to the respective topic.