简体   繁体   中英

How Retrieve Image from Firebase as Boolean data?

I am wondering as to how I can retrieve an image from Firebase storage as boolean data. I understand I must have a place-holder to display the image.

But essentially, I want to upload the image to Firebase storage. I could have it within my application and let the user never see it. However, even then, the problem arises of hiding it on the client-side, it will never appear regardless.

Ensure that the type is a boolean, which I can either set to true or false. Or something of that nature (ie 0 or 1).

And within my code, create a function/method to display the image if the .value is not != nil

But essentially I want something like this within my database. I know exactly where to set the path(s).

Firebase -->
  Users --->
   --booleanImage : false

And if I set it to true, the image should appear.

I've looked at the Firebase documentations however, I didn't find anything relevant/useful.

Sorry if this has been asked before. I have searched before asking. Alas, I haven't found anything.

Thank you.

I'm not exactly sure what you mean by saving the image as boolean data, but I get the outcome you're trying to achieve.

Once you upload an image to Firebase Storage, you need to keep it's path or download URL in your database to be able to make use of it later on. What you should do is simply save the boolean value along with the link.

Consider the following structure:

Firebase -->
   Users -->
    someUserKey -->
      imageURLOrPath: "URL or path here"
      shouldBeHidden: true
    anotherUserKey -->
      imageURLOrPath: "URL or path here"
      shouldBeHidden: false

That is assuming you need to check whether the image should be hidden or not per user. If it's a general setting for all users, you need just 1 boolean value and the structure would be slightly different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM