0

I'm wondering if it's possible to manually assign an image file that's already located in my assets file to an object property. For example, I have an image located at 'assets/images/ProfilePlaceholder.png'.

Can I give an object property, say data.image a value equal to the image file so it can be uploaded to Firebase storage? My project is written with Typescript.

Andrew
  • 432
  • 2
  • 14

1 Answers1

3

You can transform your image to base64 string (firebase does have a 10mb string data limit for utf8) or save image to remote disk and then save only public url in firebase.

Here is great answers about transforming image to base64: How to convert image into base64 string using javascript

svltmccc
  • 1,356
  • 9
  • 25
  • Will this work for me? In my method, the data.image method is used to hold an image that's loaded in from an inputEvent, so if the user submits an image then it's loaded into data.image as inputEvent.target.files[0]. – Andrew Jan 23 '20 at 08:00
  • Yes, you can transform user image to base64 or save to remote storage, you can use any way – svltmccc Jan 23 '20 at 08:01
  • Thanks, you're right. I'm using base64 string already so this method will most likely work for me. I didn't realize. – Andrew Jan 23 '20 at 08:03