How can I upload a file from AngularJS application to Firebase Hosting -
i using firebase hosting host angularjs application. using ng-file-upload grab user-uploaded image form have in application. want store user-uploaded image in folder on firebase hosting. cannot use firebase storage because need pre-determined, direct link image resource in various parts of platform. thought maybe use firebase functions upload file , store in firebase hosting. keep running cross-origin errors.
could explain how structure firebase function can upload image firebase hosting? understand, firebase function not hosted @ same location rest of firebase hosting content, not sure if makes difference.
firebase hosting exclusively versioned, deployed static content. cloud storage firebase right product you. when need "pre-determined direct link" mean need able know url before upload completes? if not, can use getdownloadurl()
in firebase cloud storage sdk.
if need know url in advance, following:
- upload file cloud storage using firebase sdk.
- create cloud function listens uploads.
- in function, use gcs node api make object public.
once above, file directly , publicly accessible @ https://<bucket>.storage.googleapis.com/<path_to_object>
.
Comments
Post a Comment