3
2 Comments

How to upload images with JavaScript

Hi guys,

I'm trying to create a profile image upload function and I'm finding most answers online using some sort of php or server side code. Is there a serverless way to simply load up the image on the browser, downsize to perhaps a 200x200 image, then push it to Firebase Storage?

  1. 3

    I'm assuming when you say serverless, you mean on the client side and not via lambdas or something along those lines. One method on the client is to convert the image to a canvas, perform the resizing, and then upload the result directly. Another option is to use something completely different like AWS S3's signed URLs which essentially provide you with a secure URL that you just upload to directly. A third, fully managed solution is to use something like Cloudinary which provides you with a URL similar to signed URLs in S3 but you can also add a bunch of parameters to it, like resizing, which will be done before the upload is complete.

    1. 1

      Woo Cloudinary looks interesting! Will look into the docs and their courses. Thank you! Converting to canvas is something I haven't seen much about, do you have any tutorial links or advice on that?

Trending on Indie Hackers
I talked to 8 SaaS founders, these are the most common SaaS tools they use 20 comments What are your cold outreach conversion rates? Top 3 Metrics And Benchmarks To Track 19 comments How I Sourced 60% of Customers From Linkedin, Organically 12 comments Hero Section Copywriting Framework that Converts 3x 12 comments Promptzone - first-of-its-kind social media platform dedicated to all things AI. 8 comments How to create a rating system with Tailwind CSS and Alpinejs 7 comments