i am trying to return the url i get inside the getsignedurl. when i try this url1 is undefined
function getPublicUrl(filename) {
var url1;
var file = bucket.file(filename);
file.getSignedUrl({
action: 'read',
expires: '03-17-2025'
}, function (err, url) {
if (err) {
console.error(err);
return;
} else {
url1 = url
console.log(url);
}
});
return url1;
}
then in another function i would call the getpublicurl
stream.on('finish', function() {
req.file.cloudStorageObject = gcsname;
req.file.cloudStoragePublicUrl = getPublicUrl(gcsname);
file.getSignedUrlis asynchronous, soreturn url1;is run beforeurl1is set in the callback function.