Copy Files From Apache to Google Cloud Storage
This short tutorial shows you how to copy files from your Apache webserver on the Google Compute Engine to your cloud storage.
The first hurdle is giving access to your projects cloud storage to your VM. By default your VM instance is not given access to cloud storage so you will need to give it permission.
- Stop your instance. ( This will take a little bit )
- Click your instance name to see the options.
- Click “Edit”.
- Scroll Down to Service Account.
- Select the custom option to adjust settings for each service.
- Find “Storage” and change the permissions to “Full”.
- Click “Save”
- Start your instance
Now give it a few minutes for the new permissions to propagate.
Log into you server via SSH and use the following command to copy the the desired files:
gsutil cp /path/to/file/filename gs://your-bucket/
If you want to transfer off the files in a directory to your bucket:
gsutil cp /path/to/directory/directory name/* gs://your-bucket/
On a side note, if you have A.D.D. like me, and like to use sub folders with spaces in the name like “My Cool Folder” you can make it work by escaping the spaces like this:
gsutil cp /path/to/directory/directory name/* gs://your-bucket/My\ Cool\ Folder