Google Cloud Storage is great because it allows storing large datasets at a minimum cost. Moreover, if you do processing on the cloud, it’s one of the best providers. Datasets are stored in what’s called a bucket. Sometimes, though it becomes necessary to transfer datasets between one bucket to another bucket. The tutorial shows how you can transfer between two buckets between different accounts with a List of object URLs option.

  1. Login to your bucket. Inside the bucket, you can see different tabs. Click on the Permissions tab. Click on the Add members button.
  2. Under New members, add the email address of the user who will access the bucket. Then under the role, scroll to Storage and assign the role of Storage Admin role.
  3. For a List of object URLs option, you need what is called a Tab-Separated value (TSV) file. The file looks like below:
    TsvHttpData-1.0      1357      wHENa08V36iPYAsOa2JAdw==      2468      R9acAaveoPd2y8nniLUYbw==

    where the first line TsvHttpData-1.0 is required. The other lines contain the HTTP or HTTPS link to the file, the size of the file in bytes and the Base64-encoded MD5 checksum of the file. More information on the TSV is here.

  4. To get the size of the file in bytes and the Base64-encoded MD5 checksum, you can use a useful tool gsutil. It allows accessing the Google Cloud Storage files through the command line without actually having to download the file. Install the gsutil in your machine using instructions provided here.
  5. Once you have installed and set up the profile using gcloud init, you can get the file size in a byte using gsutil du gs://{path-to-the-file-at-bucket}
    and gsutil hash -m gs://{path-to-the-file-at-bucket} which gives the hash md5.
  6. The file looks like this.
  7. Put that tsv file in some publicly available domain. Make note of the URL.
  8. Next login with the user who wants to access the bucket. Next, on the navigation menu, click on Transfer and then click on Create transfer.
  9. Then, choose a List of object URLs from Select source. Paste in the URL that you acquired from above. Then click Continue.
  10. Step 2, Browse to select the bucket where you want to transfer the files to. Make sure to read the Transfer options, and select best what suits you. Click Continue.
  11. You can schedule the transfer as a cron job by selecting Run daily at . . . , or you can just transfer it one time by selecting Run now. Give the unique Description to help identify the task when it is running. Click on Create to create the transfer process.
  12. Once completed, the same status is reflected in the transfer page.


Header Photo Credit: Google Developers