Upload image from URL to Firebase Storage

后端 未结 4 2297
慢半拍i
慢半拍i 2020-12-03 06:26

I\'m wondering how to upload file onto Firebase\'s storage via URL instead of input (for example). I\'m scrapping images from a website and retrieving their URLS. I want to

4条回答
  •  伪装坚强ぢ
    2020-12-03 06:49

    There's no need to use Firebase Storage if all you're doing is saving a url path. Firebase Storage is for physical files, while the Firebase Realtime Database could be used for structured data.

    Example . once you get the image url from the external site this is all you will need :

    var externalImageUrl = 'https://foo.com/images/image.png';
    

    then you would store this in your json structured database:

    databaseReference.child('whatever').set(externalImageUrl);
    

    OR

    If you want to actually download the physical images straight from external site to storage then this will require making an http request and receiving a blob response or probably may require a server side language ..

    Javascript Solution : How to save a file from a url with javascript

    PHP Solution : Saving image from PHP URL

提交回复
热议问题