S3 Upload (AWS) Questions (choosing folder within bucket, and app connect)

Hey Wappler team,

Can you advise how to do the following:

Choose a folder to upload a file to, not just the bucket (e.g. we have a number of folders within a bucket that separate out user avatars, cover images etc.).
If preffering to use App Connect S3 Upload how would do the above, and also return the full URL path once upload has been completed so we can then update the users avatar url in the database.
Lastly, can we do any image processing on the AC side? Currently we upload an image, resize it twice then update the DB with 3 file urls (not on Wappler) which I’d like to recreate.

It looks like SC would be the only way to do this - but I still can’t see how to choose folders within a bucket?

The concept of folder is different in S3. You don’t need to create any. They are just a part of the file name.

So just specify a path prefix to the key/filename when you store a file, and the folders will be auto created.

Then to list a folder files - just specify the path prefix in listFiles action.

1 Like

Hi George,

I’ve been able to do everything up to the part where I want to put images into a certain path in AWS.

The pre-existing path is www.awsurl.com/user-avatar/

I’m able to upload the file to the server, resize it, connect to S3 and put the file to S3 - everything works a treat.

But I cannot mirror the path in AWS - it just keeps creating blank folders, and then it’s own folder structure (I know AWS does not consider folders as the same).

In addition, I’ve been trying to easily return the file path - I assumed using the ‘output’ option on ‘Put File’ would do this, but it doesn’t - so I can create the strong myself using the file name created from the resize step and just manually adding the S3 bucket URL.

Can you advise the best way in Server Connect actions, including an image resize to mirror the AWS file path please?

save image path
Screen Shot 2020-09-04 at 6.21.30 pm

Put file section
Screen Shot 2020-09-04 at 6.22.06 pm

And it creates a new blank ‘folder’ in AWS and then a new ‘user-avatar’ ‘folder’ and then puts the file in there.

I’ve tried a few different variations, each time it creates the blank folder, and then public or user-avatar folder paths.

The path on AWS should be specified in the key name you pass - just as prefix to the file name - it will be auto created there

2 Likes

Thanks George. I did that initially and it created a blank folder and then the correct folder.

Noting the actual folder I want to use already exists in AWS.

@George - so I’ve been able to get the basic file structure working, without the blank folder being created - however I’m still having the same issue if I use image manipulation on the server side, save the image and then try to put that image to S3.

This is my server connect
Screen Shot 2020-09-08 at 9.04.04 am
My save image action
Screen Shot 2020-09-08 at 9.04.38 am

My S3 AWS action
Screen Shot 2020-09-08 at 9.05.08 am

What it should create is amazinawsurl/bucketname/user-avatar/{guid}_thumbnail_255x255{ext}

What Im getting instead is this:
https://MYWEBSITE-public-live.s3-us-west-1.amazonaws.com/user-avatar//public/user_uploads/avatars/8f31672c-8488-4544-a77d-ad26b9ed30eb_thumbnail_255x255.jpeg

I can’t figure out why this action is adding the path incorrectly?

1 Like

Loving the S3 integration! Was just about to ask this question of how to upload to a directory within a Bucket… Answer within a minute. Superb.

:slight_smile:

1 Like