0

I am using these codes to save image's url:

  await destA.save("base64Image", {
    metadata: {
      contentType: "image/jpeg",
    },
  });
  const metaData = await destA.getMetadata();
  const url = metaData[0].mediaLink;

I activated Uniform access control. But it is error when I want to display it om Flutter. The error I think is: "Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object." Is this the correct way to save metadata file url? Or maybe i was wrong at the beginning.

This is the saved url

Wege
  • 177
  • 2
  • 11
  • 1
    authenticate your call via Oauth 2.0 access token – MANISH DAYMA Oct 11 '22 at 06:09
  • I am using Cloud Functions for these. I thought when we signed up to use the app, we already authenticate it with Oauth 2.0 access token? Is there any way to get download url in a simpler more way like in firebase client sdk in flutter? – Wege Oct 11 '22 at 06:12
  • I have been trying to use this anwers, but no luck at all. https://stackoverflow.com/questions/42956250/get-download-url-from-file-uploaded-with-cloud-functions-for-firebase?rq=1 – Wege Oct 11 '22 at 06:42
  • 1
    Please check these helpful documents, where you can find the configuration setup required to get a download URL for flutter:https://firebase.google.com/docs/storage/security/rules-conditions#public , https://firebase.google.com/docs/storage/flutter/download-files#download_data_via_url and https://firebase.google.com/docs/storage/flutter/create-reference#create_a_reference – Vaidehi Jamankar Oct 12 '22 at 12:38
  • So the whole point is that we can't save each's url in database, but instead we have to use the firebase storage client sdk to load its url using the file name only, @Vaidehi Jamankar??? – Wege Oct 13 '22 at 01:48
  • 1
    It is recommended to use the To upload a file to Cloud Storage, you first create a reference to the full path of the file, including the file name. You cannot upload data with a reference to the root of your Cloud Storage bucket. Your reference must point to a child URL. – Vaidehi Jamankar Oct 13 '22 at 07:25

1 Answers1

1

Cloud Storage for Firebase lets you upload and share user generated content, such as images and video, which allows you to build rich media content into your apps. The basic steps involve the following in broad

  1. Create a default Cloud Storage bucket
  2. Set up access
  3. Create a Cloud Storage reference on Flutter
  4. Upload files with Cloud Storage on Flutter
  5. Get a download URL
  6. Add File Metadata

As mentioned above ,it is recommended to use the To upload a file to Cloud Storage, you first create a reference to the full path of the file, including the file name. You cannot upload data with a reference to the root of your Cloud Storage bucket. Your reference must point to a child URL.

You can find more information about Error Handling issues here. And a similar example here.

Vaidehi Jamankar
  • 1,232
  • 1
  • 2
  • 10