Reputation: 305
I am working with Google API storage to save my uploaded files in cloud.
I have uploaded a pdf file into that storage and it returns a self link for that file, as follows, https://www.googleapis.com/storage/v1/b/mystorage/o/file.pdf
When I am trying to enter this link in browser, it shows the following json object,
{
"kind": "storage#object",
"id": "myStorage/myFile.pdf/2152448693558409",
"selfLink": "https://www.googleapis.com/storage/v1/b/myStorage/o/myFile.pdf",
"name": "myFile.pdf",
"bucket": "myStorage",
"generation": "2152448693558409",
"metageneration": "1",
"timeCreated": "2018-04-23T12:35:35.579Z",
"updated": "2018-04-23T12:35:35.579Z",
"storageClass": "REGIONAL",
"timeStorageClassUpdated": "2018-04-23T12:35:35.579Z",
"size": "3028",
"md5Hash": "EF0GjR1EyvYYbMKh44wqla==",
"mediaLink": "https://www.googleapis.com/download/storage/v1/b/myStorage/o/myFile.pdf?generation=2152448693558409&alt=media",
"crc32c": "uSlJNw==",
"etag": "COO6irK00NoCEAE="
}
I copied that media link and pasted in browser, but the pdf file is downloaded instead of viewing that in browser.
Can someone please assist in this, how to view the files?
Upvotes: 1
Views: 4472
Reputation: 2319
In order to view your file in a browser you have to either:
https://storage.googleapis.com/[BUCKET_NAME]/[OBJECT_NAME]
READER
role, for your Google account, to the file and access it with a link:
https://storage.cloud.google.com/[BUCKET_NAME]/[OBJECT_NAME]
Upvotes: 1