I uploaded image using Firebase sdk on Flutter, on Flutter side i can usually just call getDownloadUrl() on the reference, then i want to get that url on my Cloud Function trigger so if image is uploaded on Firebase Storage i would get the download URL and post it on firestore.
I have tried getting metadata mediaLink but it is not the same url which i can found manually from browsing firebase storage console.
exports.generateThumbnail = functions.storage.object().onFinalize(async (object) => {
const db = admin.firestore();
const filePath = object.name;
const contentType = object.contentType;
const fileDir = path.dirname(filePath);
const fileName = path.basename(filePath);
const jobId = fileName.replace("poster_","").replace(".png","");
const bucket = admin.storage().bucket(object.bucket);
const file = bucket.file(filePath);
const posterMetadata = await file.getMetadata();
const posterFileUrl = posterMetadata[0].mediaLink;
return functions.logger.log('url: '+posterFileUrl );
}
Using that url i got "Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object." error,
How to get this generated link, which we can found on firebase storage console