Create Singed URL:
Create a Signed URL Using gsutil:-
— A Singed URL is a URL that provides limited permission and time to make a Request.
— Singed URLs contain authentication information in their Query String, allowing users without Credentials to perform specific actions on a source.
Key Parameters in Sign URL:-
- X-Goog-Algorithm: - The Algorithm used to Sign the URL.
- X-Goog-Credentials: - Information about the Credentials used to Create the Signed URL.
- X-Goog-Date: - The date and time the Singed URL became usable, YYYYMMDD ’T’ HHMMSS ‘Z’
- X-Goog-Expires:- The length of time the Signed URL remained Valid, measured in sec. In our case we’ll take 60 Sec. Max. Duration is 60, 4800 Sec i.e 7days.
- X-Goog-SignedHeader: - The Header that had to be included as part of any request that used the Signed URL.
- X-Goog-Signature: - The authentication String that allowed request using this Signed URL to Access Resources.
Labs:-
Go to Cloud Storage:
— Create a Bucket gcs-datahouse
— Upload a file like an image.
— Now Go to APIs & Services
— Credentials
— Create Credentials — Service account — If not exist then create it otherwise leave it.
— Click on Service Accounts
— KEYS
— ADD KEY
— Create new key
— Selecte JSON
— Create
Now Go to GCP terminal:-
$ sudo rm -rf $HOME
$ restart
$ ls
— Click on upload via GCP console on terminal itself.
— Upload key which you created earlier.
$ sudo su
$ ls
$ pip install pyopenssl -y
$ gsutil signurl -d 60s key.JSON gs://gcs-datahouse/image.JPG
— Authorize
— We’ll get an url using this URL anyone can see the data for given timeline.
— Delete the key
— Delete files from bucket
— Delete Bucket
🙏 thanks
ConversionConversion EmoticonEmoticon