Google cloud storage(Optional)

If you want to use Google cloud storage to save and serve the image assets, please follow this section. Otherwise you can skip. By default, image assets are being serving in the project.

Creating Bucket

  1. Go to https://console.cloud.google.com/ and login.
  2. Go to Cloud Storage > Bucket.
  3. Click Create.
  4. Fill up a Name.
  5. Click Continue.
  6. Keep clicking Continue.
  7. Make everything default.
  8. And create a bucket.
  9. Uncheck Enforce public access prevention on this bucket.
  10. And click Confirm.
  11. Your bucket has been created.
  12. We are serving the images from a folder (uploads). So, please create a folder inside the bucket. Name the folder uploads.

Giving permission

  1. Go back to the bucket and check the checkbox.
  2. Click on Permissions.
  3. Click on SWITCH TO FINE-GRAINED from Access control section.
  4. Click on Fine-grained from the pop up and click Save.
  5. Now click on ADD PRINCIPAL.
  6. In the new principal field, put AllUsers.
  7. In the select a role section, select Cloud Storage > Storage Object viewer.
  8. Now save and click ALLOW PUBLIC ACCESS.
  9. Your bucket is now publicly accessible. You can access the files publicly from the bucket now.

Setting up

  1. Login to Admin panel and go to Setting > Media Storage page.
  2. Select Media Storage to GCS
  3. Fill the Thumb Prefix Value. This value will be used in prefix of the name of the Thumb image. As a thumb images is generated while uploading an image from the admin panel.
  4. Fill the Default Image field. This is the name of the defult image. If any image got missing, this image will be used.
  5. Put your the URL of your bucket in theCDN Url field. eg. https://storage.googleapis.com/test-ishop/uploads/
  6. To get the value of Google Cloud Project ID, go to Cloud Storage > Bucket.
  7. Click on the project dropdown from the header.
  8. A pop up will be open. Copy the ID from here. and paste it in the Google Cloud Project ID field in the admin panel.
  9. Put the bucket name in the Google Cloud Storage Bucket field.
  10. And put the folder name inside the bucket in the Google Cloud Storage Path Prefix field. eg. uploads
  11. Click Save.

Service Account set up

  1. Log in to the Google Cloud Console.
  2. Navigate to the IAM & Admin page.
  3. Click on "Service accounts" on the left-hand side menu.
  4. All the service account is listed here. Initially one service account will be found here. Click on on that from here.
  5. If there is no service account here, Click on the "Create service account" button at the top of the page. Enter a name for your service account and optionally provide a description. Choose a role for your service account. For Google Cloud Storage, you can choose the "Storage Object Creator" or "Storage Object Admin" role depending on the level of access you want to grant to the service account.
  6. Click on the "Create" button to create the service account.
  7. After the service account is created, click on the "Actions" button next to the service account and choose "Create key".
  8. Choose the key type as "JSON" and click on the "Create" button. This will download a JSON file containing the private key for your service account.
  9. Put the contents of the files in the service-account.json file from the root of your project.

Use a subdomain as CDN URL(Optional)

If you want to use a subdomain instead of the google cloud storage URL, Please follow the steps.

  1. Log in to the Google Cloud Console.
  2. Navigate to the Network Services > Load Balancing.
  3. Click on CREATE LOAD BALANCER on the header.
  4. Click START CONFIGURATION from the HTTP(S) Load Balancing
  5. Click CONTINUE. Keep everything default.
  6. Put a name. Protocol should be HTTP
  7. In the IP ADDRESS field, click on CREATE IP ADDRESS
  8. Put a name here. Click on Reserve
  9. Now click on ADD FRONTEND IP AND PORT
  10. Put a name. Protocol should be HTTPS
  11. In the IP ADDRESS field, Choose the reserved IP address you created before.
  12. In the Certificate field, Click CREATE A NEW CERTIFICATE.
  13. Put a Name, Choose Create Google-managed certificate.
  14. Put your Domain Name. And click Create
  15. Click Done.
  16. Now the next step is to create a Backend configuration.
  17. Click on CREATE A BACKEND BUCKET.
  18. Put your bucket name and browse the desired BUCKET.
  19. Click on OK and then Create.
  20. Now click on the Load balancer, Copy the Ip address from here.
  21. Navigate to the Cloud DNS.
  22. If you don't have a zone here, Please create one.
  23. After creating a zone, click on the zone.
  24. Click on ADD STANDARD.
  25. Put your desired Subdomain name.
  26. And put the IP address here from the last step.
  27. Click Create.