Skip to content
Advertisement

Compressing an Image before Uploading it to Firebase Storage

I am trying to Compress an Image before Uploading it to Firebase Storage using SiliCompressor library , but it seems not working , the ProgressDialog doesn’t stop. What i first did was to pick the Image from the Gallery into an ImageButton by clicking an ImageButton. Below is my code.

JavaScript

So now am having a Method startPosting() which Uploads data By a click of Button to Firebase Storage. Below is my code.

JavaScript

Now if you see in that Method , my essence was to Compress an Image which is loaded in the ImageButton, then Afterwards it Uploads to firebase. This is the line of Silicon Compressor which tries to compress an image loaded in the ImageButton.

JavaScript

I got this lib from this link of Github. https://github.com/Tourenathan-G5organisation/SiliCompressor

So where am i wrong please because the Image is not Uploading but i want it to Upload while it’s compressed.

Advertisement

Answer

Here is what I have written, you can try it.

JavaScript

Your startPosting method should be like this

JavaScript

Below is the class ImagePicker that have series of methods to do your work

JavaScript

The ImagePicker Class have all the methods of handling compression as well as rotation of image.

Hope it will help

Thanks to this link for uploading file ref

Uploading files on firebase

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement