Provision Cloud Storage on GCP And Upload An Image
Video
Introduction
This tutorial is designed for individuals with a basic understanding of cloud concepts and who are interested in learning how to set up Cloud Storage on Google Cloud Platform (GCP) and upload an image. We will also look into how to make the image publicly available on the Internet as well as how we can keep track on different versions of the file. We will go step-by-step through the process, emphasizing best practices and troubleshooting.
Method
- We will use the GCP web console to manually provision a Cloud Storage bucket
- We will upload an image to the bucket and make it publicly available
- We will turn on versioning and life cycle management in order to keep track of changes to the file over time
Prerequisites
- A Google Cloud account. If you don’t have one, sign up here.
- Basic knowledge of cloud computing and familiarity with the GCP web console.
- Two different images with the same file name to upload
Provision a Cloud Storage Bucket
Log into Google Cloud Console
- Go to the Google Cloud Console.
- Log in using your Google account.
Create a New Project (if you don’t have one already)
- In the console, go to the project selector page.
- Click on “New Project” and enter a project name and billing details.
Navigate to Cloud Storage
- With your new project selected, navigate to the “Navigation Menu” (three horizontal lines in the top left corner).
- Scroll down and select “Storage” under the “Storage” section.
Create a Storage Bucket
- Click on âCreate bucket.â
- Provide a unique name for your bucket. This name has to be globally unique across all Google Cloud Storage.
- Choose a region for your bucket. For lower latency, choose a region closest to your users.
- Under “Choose how to control access to objects,” select âUniformâ to apply permissions uniformly at the bucket level.
- Click on âCreate.â
Enable Versioning on the Bucket
- After creating your bucket, click on its name to open its details page.
- Click on the âConfigurationâ tab.
- Scroll down to the âObject versioningâ section and click on âEdit.â
- Toggle the âEnable versioningâ option to ON.
- Click âSaveâ to apply the changes.
Your Cloud Storage bucket is now ready to keep files.
Upload an Image To The Bucket
- Navigate back to the âObjectsâ tab in your bucketâs details page.
- Click on the âUpload filesâ button.
- Select the image file from your computer that you wish to upload and confirm the upload.
Make the Image Publicly Accessible
- Go to the “Permissions” tab for the bucket
- Click on âGrant Accessâ
- In the âAdd principalsâ field, enter
allUsers
. - Assign the role to âCloud Storageâ and âStorage Object Viewer.â
- Click âSave.â
- Confirm “Allow public access”
Your image is now publicly accessible. You can click on the public URL provided to verify that it’s accessible in your web browser. You might need to refresh the browser in order to see the change.
Troubleshooting
- If you encounter issues accessing you image, make sure you use the public URL
- If the wrong version is shown it might be caused by caching the old image in the browser or elsewhere. Change the cache settings.
Final Thoughts
- Making your data publicly accessible means anyone on the internet can view your files. Always ensure that the data you’re making public does not contain sensitive or private information.
Don’t Forget
Google Cloud Storage is a paid service, and charges apply for storage, network usage, and other features like operations and retrieval. Make sure to review the current pricing and manage your resources accordingly.
Don’t forget to delete all resources once you are done with this tutorial.