0
votes

I am currently using AngularFire to upload my images to firebase storage and then resize using the firebase image resize extension. This is working well for my profile images at 200x200.

I now want to upload and resize some other images at a different size of 500x500.

I have made another bucket and installed/configured another instance of the firebase extension to resize at 500x500 for anything uploaded to the new bucket.

I can't figure out how to switch between buckets in my app so I can upload profile images to one and the other images to the other bucket.

Has anyone been able to do this with AngularFire?

NOTE: -I know you can do this with the firebase JS SDK (raw firebase) but I would like to do it with AngularFire if possible to avoid changing my code.

-I also know you can specify multiple resize resolutions with one resize extension instance but this would create a load of unnecessary images as it would create both 200x200 and 500x500 for each upload.

1

1 Answers

1
votes

As far as I can tell it is not possible to do this fully with AngularFire. I ended up refactoring my code to use raw Firebase for this particular part. It is pretty similar but the calls and objects are different to what I was using with AngularFire.

constructor(private afStorage: AngularFireStorage) {
   this.defaultBucket = this.afStorage.storage.app.storage();
   this.otherBucket = this.afStorage.storage.app.storage(OTHER_BUCKETNAME);
}

const storageRef = this.otherBucket.ref().child(FILENAME);
   storageRef.put(file).then((snapshot) => {
   console.log('Uploaded a blob or file!', snapshot);
}