I am trying to download an object from a google cloud store bucket using the method 'get' as described here https://cloud.google.com/storage/docs/json_api/v1/objects/get
It says in there that it "Retrieves an object or its metadata"
I want to use the API to download the object as mentioned in the documentation but all i can get is a dict containing the metadata for the object.
I tried using the selfLink and mediaLink provided in the metadata but to no avail.
http_request=resource.objects().get(bucket='bucket-name',object='Object-name')
http_response=http_request.execute()
resource is a valid authenticated resource object as the other methods are working fine.
Now i know i can use the python client api to download the object but is there a way this can be done using the 'get' method ? Or am i missing something obvious(which is possible as i am new to gcp)
As you said, that get request can obtain the object or the metadata of an object inside of your bucket. Using the call that you shared it will get only the metadata, if you want to obtain the object, you have to specify a destination with the "-o" flag, the command should be like the following:
curl -X GET \
-H "Authorization: Bearer [OAUTH2_TOKEN]" \
-o "[SAVE_TO_LOCATION]" \
"https://www.googleapis.com/storage/v1/b/[BUCKET_NAME]/o/[OBJECT_NAME]?alt=media"
Bear in mind that if you want to generate a token you can generate it with the following command:
gcloud beta auth application-default print-access-token
I am able to do it this way . However I was hoping that i could do this in python . But i think to do what i want in python the client api will have to be used. Thanks for the info.