Closed callanbright closed 3 years ago
Hi @Callan93,
I haven't been able to reproduce the image loading failure you're running into here (full repro attempt below).
Can you verify that you recieve a 200 for your object using curl?
curl -sI https://storage.googleapis.com/pt-item-icons/3rd-age-amulet.png
Is it possible that the base64 image data is somehow corrupt or malformed?
Thanks @BenWhitehead
I can confirm that I receive 200:
> curl -sI https://storage.googleapis.com/pt-item-icons/3rd-age-amulet.png
HTTP/2 200
x-guploader-uploadid: ABg5-Uwkln57gPwVAVZ7jKpW-qGrERLqkt2WnS99OrxOqg8FrL0ttAS4q428T8Zs0lrLLW8-X5LuJwIei0rf2fNcDJMlCzNTqA
expires: Thu, 20 May 2021 03:39:38 GMT
date: Thu, 20 May 2021 02:39:38 GMT
cache-control: public, max-age=3600
last-modified: Wed, 19 May 2021 07:24:59 GMT
etag: "127e8916f1a35fde0d8ccf823d1e0481"
x-goog-generation: 1621409099518342
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 500
content-type: image/png
x-goog-hash: crc32c=PP3LVQ==
x-goog-hash: md5=En6JFvGjX94NjM+CPR4EgQ==
x-goog-storage-class: STANDARD
accept-ranges: bytes
content-length: 500
server: UploadServer
alt-svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
When I curl the contents I receive the base64 I expect:
> curl https://storage.googleapis.com/pt-item-icons/3rd-age-amulet.png
iVBORw0KGgoAAAANSUhEUgAAACQAAAAgCAYAAAB6kdqOAAABPElEQVR4Xu2Vv0vDQBTHe2PHDEIIFI5SpEMoodRBqEsL0kFKC6kRqaDoIji4uTjZRUHwT/7aa8iPe4mQq7m7DPnAW/Je7n24e8d1Oi0tLY2EQS20wnDiOEqhUSqTKe6CHPm6gPND0NVqIG6Ub1IWZUJ0pRooytCKDENC1WQE2oXk3aHZIo0TEhzzT2VUF1eZt6NQEdIuI6gqpH12EqoIFWX+rv03cjOapXnNMgIqZOWZyJM1FfG48BFOT6VvBmUEstD7xsfTfGBLJiE+nt3NCNsLjmgqmqs8J7XD8HUXHERWZ54kYkXm52GC8LyHy8DFetxNhWilIRiWYwcz34V7v5+diON6EkvRSkMwfIQcrwsP3sswlXqexUdHqw3B8Bn18X3bT+UsDnTCfpa2A7xd9Zogk2D1qpfTKBnd/ALyniY30GleuwAAAABJRU5ErkJggg==%
When I put this data into a base64 image viewer, it shows the image I expect:
It appears the client library did perform the upload correctly, and the data that was uploaded was also correct.
With content-type being image/png
and the data being correct I would expect the image to display when viewed in my browser, however this is not the case. Viewing https://storage.googleapis.com/pt-item-icons/3rd-age-amulet.png in my browser results in a tiny white square:
Looking at the network tab I can see a 304 response:
Request URL: https://storage.googleapis.com/pt-item-icons/3rd-age-amulet.png
Request Method: GET
Status Code: 304
Remote Address: 142.250.204.16:443
Referrer Policy: strict-origin-when-cross-origin
Is there any additional config I should be adding to iconImageFile.save
to make the asset viewable in the browser?
You shouldn't have to do anything else with your method call to get things to work.
I tried downloading and viewing the image and was met with this error in my image viewer
It seems that some of the image metadata is missing (I'm seeing dimensions when I click into the details). It would seem that the original data that was written is not well formed and the browser is likely having a hard time figuring out how to render it.
Regarding the permission issues you ran into
my-email@example.com does not have storage.objects.getIamPolicy access to the Google Cloud Storage object.
I have clarified with a teammate, you need to ensure your user has one of the roles which contains storage.objects.getIamPolicy
, a full list of roles can be found here https://cloud.google.com/storage/docs/access-control/iam-roles . Project Owner does not by default have storage.objects.getIamPolicy
so one of those roles will need to be added.
I believe this has been addressed from the nodejs-storage perspective, feel free to re-open or create a new issues if this hasn't helped you resolve your issue.
Environment details
node:14.16
docker image@google-cloud/storage
version: 5.8.2Steps to reproduce
Before uploading, I receive the pictures in a JSON object mapping filename to base64 data:
I am then using the nodejs client library to upload the data. The pattern I am following is:
When I run the above code, the uploads appear to all succeed.
My bucket
My bucket is single-region, standard storage with fine-grained ACLs enabled. I had to enable fine-grained ACLs because of this issue with the client library when uploading data as base64: https://github.com/googleapis/nodejs-storage/issues/1230
I have granted
Storage Object Viewer
permission toallUsers
in the bucket:When looking at the picture in the bucket, its permissions say "Public Access": "Public to internet", however the picture does not load below:
The image is also not accessible by the public URL.
If I attempt to
Edit Permissions
for the picture in the GUI, I am told:Is this a bug?
How can I make the picture uploaded by my code publically viewable?
How come setting
public: true
andpredefinedAcl: 'publicRead'
does not have the desired effect?