1

I utilize Google Cloud Storage to host my images and PDFs. However, the challenge arises due to the lengthy URLs generated by Google Storage, making it impractical to share through text messages. Is there a solution to shorten these URLs or to employ a custom domain name, replacing the default "https://storage.googleapis.com"?

I am using Django for backend.

Sample Url - https://storage.googleapis.com/mob-uat-server/products/images/Polycab/Polycab%20Elanza%20NEO%20Storage%20Water%20Heater%2C%2015%20L%20%28POL-ElanzaNeo-15%29/129LEG115.jpeg?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=mobdemandfrontend%40appspot.gserviceaccount.com%2F20240115%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20240115T075737Z&X-Goog-Expires=86400&X-Goog-SignedHeaders=host&X-Goog-Signature=57c12fd43450aae652531a4c97954a43b19766e3f30aca51eacb942368ff66ac90d6bc516c275097a727f1c86062a7194dfdb33e48edd7dc462a8b94034882cb7f75d19a2c88d3178adbd48bb841d95d5abec8d3f02f1fd70a4e4b782108af9d3ac6a31039f65f787f8d603b8443fd92f91df7c1e9fa444a4bf861bec2d10311bca156e132399afcdb3a35720e7242b8283778a16203cff98aece6264b84c63a6a7cccac3da7bde4a4f718946f51177e12ae0048c7d029fd0b0cab93019b6f7364d90dffe85a1a48eea47079865221744b63d0657170e91afa78b9968db72432a634abc99f1b63906e4faa58599923b9db5ff6e80185f66fb67bc27429e8907a

3
  • 3
    Using a third-party URL shortener will not help you. You are using Signed URLs. 1) You have very long object names. 2) The query parameters are the largest part and you cannot modify those parameters. To answer your question, yes you can use your domain name, but that will require adding a load balancer. There is a trick that you can do. Implement your own shortener. When you create the Signed URL, also create a short URL. Store both in a database and serve the short URL from your web server, which redirects the client to the long URL. Commented Jan 15 at 8:11
  • 1
    The domain / path part of that URL isn't really that long, its the query string which is long. Also that particular URL is a signed URL which is why the long query string which is used for auth purposes... If your user already has access to the gcs bucket / object you can skip the signed url and give them a url to the object directly Commented Jan 15 at 8:12
  • 1
    John shared the correct solution with your own shortener service Commented Jan 15 at 8:16

1 Answer 1

2

Answering as a Community Wiki, so that it may help others too.

As John suggested, Using a third-party URL shortener will not help you as you are using Signed URLs.

  1. You have very long object names.

  2. The query parameters are the largest part and you cannot modify those parameters.

To answer your question, Yes you can use your domain name, but that will require adding a load balancer. You can refer to this Documentation.

Also as @John Hanley suggested,

There is a trick that you can do. Implement your own shortener. When you create the Signed URL, also create a short URL. Store both in a database and serve the short URL from your web server, which redirects the client to the long URL.

Not the answer you're looking for? Browse other questions tagged or ask your own question.