Reputation: 31
I was trying to change the default bucket to firestorage, i've looked it up on the internet and I found on the firebase page the following code:
bucket2 = firebase.app().storage(bucket);
However, before, i was using:
this.afStorage.upload(remakeNewPath, file);
to make the upload. Now, if I do this:
this.bucket2.upload(remakeNewPath, file);
It does not work anymore, it seems that the value of bucket2 doesn't have the property upload like this.afStorage did. How would I go about uploading it now that i'm using a diferent way?
Upvotes: 0
Views: 345
Reputation: 3774
You can use the BUCKET
injection token to customize the storage bucket and afterwards use one of the following methods to upload blobs: put()
, putString()
, upload()
.
Upvotes: 0
Reputation: 599121
From looking at the documentation for AngularFire2, it looks like you can set a custom bucket with:
import {AngularFireStorageModule, BUCKET } from '@angular/fire/storage';
@NgModule({
providers: [
{ provide: BUCKET, useValue: 'my-bucket-name' }
],
...
})
export class AppModule {}
Upvotes: 0
Reputation: 1486
Yes there is not function called upload in this appraoch.
You need to use the following code to upload the image to the new path:
firebase.storage().ref().child(remakeNewPath).put(file);
here remakeNewPath is the path and you need to define the storage bucket in your configuration used for firebase.
Upvotes: 1