S3 Upload - How Do I Create and Record a Unique Uploaded Filename With AWS S3

I’d love to hear what the folks at Wappler think is the best methodology with S3 to achieve what I wish to do…

The user experience I need for a multi-user app is:

  1. The user uploads a file which is to be stored in my AWS S3 bucket.
  2. During the process, the file is given a unique name such as hUbdgU7hdGF.jpg
  3. In a database of filenames, I record the exact path to their file, which they can they link to when they send emails from within my app… so a path like mys3bucket.amazonsurl.com/hUbdgU7hdGF.jpg

I’ve never really worked with files in Wappler before, so am starting from a “file newbie” perspective. Was waiting for the S3 moment to start!

So from what I can see, it looks like I’ll need to do something like this:

  1. Upload the file (say my_image.jpg) to the server.
  2. Rename the file on the server to xyz.jpg
  3. Upload the file from the server to S3.
  4. Store the filename in my database as mys3bucket.amazonsurl.com/xyz.jpg

In which case I won’t be using App Connect S3, but I’ll be using Server Connect S3.

Is this the best way to achieve what I am looking for?

Best wishes,
Antony.

Have you checked out Wasabi?


They claim price is 80% less than AWS S3 & faster than the competition!

No… but am wanting to keep everything within AWS for now to prevent having a million different platforms I am maintaining!

I understand but I find amazon’s interfaces nasty. It feels confusing like the product is separated anyway.

Fair enough, but I’d prefer to keep this thread to one that answers my question. Feel free to start a coffee lounge thread about S3 suppliers!

Normally you give the filename as “key” to the S3 functions and that is what you store.
You can however just generate the key yourself using a date stamp or other hash to make it unique.
Just pass that to S3 as key and it will be used to save the file there under that name.

Thanks for that @George!

So I can see the key field is populated by $_GET.name in the server action:

So is this $_GET.name automatically populated by the filename when I use the S3 App Connect?

So I just need to extract the file extension from $_GET.name and then create the new filename and then place that value in the Key field.

I get it!