Upload images via Firebase Storage, make them available to everyone via a shared link

Whenever I upload an image to Firebase Storage , the file is only available through the download link .

What if I want someone to access this file?

If I go to the Google Platforms repository and enter the same bucket that Firebase uses, I see that the "Public Link" is not checked.

How can I allow this to be automatically checked when uploading a photo?

Such actions can be performed using the Google Cloud Storage API , but for him it is not like Firebase .

In addition, all images uploaded using Firebase have Content-Type of "application/octet-stream".

Since I'm uploading an image, I would like it to have either " image / jpeg " or " image / png ". Is there a way to change metadata?

UPDATE: The reason I ask about this is because if you create an application using Instagram, for example, from a thousand images. Requesting a download link for each uploaded image is not required since the images in the questions should already be open to the public by default. Downloading a Firebase file prevents this, and each user must make one request for an image (which may be tons of images to run the application). For example, a Firebase Flame subscription plan has a limit of 100,000 uploads / downloads per month. This makes it unrealistic to create an image feed with thousands of users with thousands of image requests each. Files must be able to create a public link at boot time, just like the Google Cloud Storage API itself.

+4
1

Google Cloud Storage , Firebase.

, Google, , , ACL- publicRead.

URL , Firebase, , , , . , , URL- ?

File Metadata , , :

// Create file metadata to update
FIRStorageMetadata *newMetadata = [[FIRStorageMetadata alloc] init];
newMetadata.contentType = @"image/jpeg";

// Update metadata properties
[myRef updateMetadata:newMetadata completion:^(FIRStorageMetadata *metadata, NSError *error){
  if (error != nil) {
    // Uh-oh, an error occurred!
  } else {
    // Updated metadata for 'images/forest.jpg' is returned
  }
}];

, .

+3

Source: https://habr.com/ru/post/1658432/


All Articles