Monday 1 May 2017

Access Denied when creating signedUrl on Google Storage Object in App engine

Exact text: "Access Denied. Caller does not have storage.objects.get access to object on (url)"

I currently have 2 projects on google services. One that is a resource for an Android/iOS app that will upload images to google cloud storage (more so firebase storage). The other is a node.js server that detects when an image is uploaded and sends an email with a signedUrl to that image.

The node.js server has the following google storage setup and function that is called:

var storage = require("@google-cloud/storage")({
   keyFilename: "google_secret.json",
   projectId: 'xxxxxxxxxxx' 
});

function getImageFromGcloud(x, y, time, date_string) {
    var bucket = storage.bucket('bucket-name');
    var storage_ref = 'Incomplete_Scans/' + date_string + "/" x + "_" + y + "_" + time + ".jpeg";

    bucket.file(storage_ref).getSignedUrl({
         action: 'read',
         expires: '03-17-2025'
    }, function(err, url) {
         if (err){
             console.error(err);
             return;
         }
         console.log("Sent email");
    });
}

The link provided from getSignedUrl used to work, when clicked it would open a new tab with the image there. However as of recently, it had just stopped. Perhaps it has to do with the permissions, however nothing I'm doing is working. Any ideas?

Thank you in advanced.



via Eric Salazar

No comments:

Post a Comment