I'm stuck in resizing images on firebase storage. I know the way to resize and make thumbnail when users upload images. However, I like to know images already uploaded on firebase storage. Because images are already uploaded on our server and I really need to resize those images. Image size is big, so component render is really slow. If you have any tips, please let me know with your code. Thank you.
1
votes
You can create a cloud function that create a smaller version each time you upload or for all existing images
– phoenixstudio
You're going to have to write some code to identify all the images in storage that need to be resized, download each one, resize it, then upload it back.
– Doug Stevenson
@DougStevenson, I know but how? cause I don't have File but url that I could get it using 'getDownloadUrl' from firebase storage.
– Mingyu Jeon
A full description is too long for Stack Overflow. You have a series of tasks that you can research and implement individually. If you're having problem coding any one of them, please post a new question to share the code, what it's supposed to do, and how it doesn't work the way you expect.
– Doug Stevenson
1 Answers
2
votes
I was looking for a simple solution.
However, there was a simple way.
I had to download all of the images, resized and upload them.
I used GCE for this and if you use gsutil
, you could simply do this.
Create instance on google cloud platform to perform this process.
I talked to google cloud platform team, cloud function is not a good idea for this because it might cause some issues.
when you are all set, start with this command.
gsutil cp -r gs://my-bucket/data [path where you want to download]
and to resize images I used sharp
.
after resize all of images, you simply upload like this.
gsutil cp -r [path your images] gs://my-bucket/data
That's all.