S3 Upload - path returning incorrect value [object] [object] or simply returns 500 error

======== TEMPLATE BUG FORM ========

Wappler Version : 3.3.1
Operating System : Mac
Project type: NodeJS, MySql8

Expected behavior

I should be able to upload to S3 and choose path as the output to append the correct filename to my database field.

Actual behavior

it just creates [Object] [object] when I try to input the value into the DB using only the output ‘path’ of the S3 PUT action.

To be precise, if I manually include the full bucket URL and then apend the PUT path output this is what I get:
(https://websitename-public-live.s3-us-west-1.amazonaws.com/user-avatar/)[object Object]

If I just use the PUT output without manually including the URL in the string, it just errors (500):

stack: "Error: ER_BAD_FIELD_ERROR: Unknown column ‘ETag’ in ‘field list’

How to reproduce

Upload a file to S3 via Server Action and try to use the output of the PUT file into the DB to then use the image.

I checked the S3 API and it seems that AWS doesn’t return the url in the NodeJS SDK after an upload, it only returns the ETag. This is different from the PHP version where it returns it as ObjectURL property. The action step returns the exact result as we get it from the S3 API.

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property

The url is easy to get, it is the S3 endpoind with the key added to it. The key is what you set yourself in the Put File step, so you should know what that it.

Ok, thanks Patrick.

They Key isn’t really easy to get.

Let’s say I have two resize actions within the same Server Action, one to 255x255 and the other to 60x60.

I set the unique name for the save file action as: {guid}_thumbnail_255x255{ext} and {guid}_thumbnail_60x60{ext}.

So I need to get the unique guid from each save action to add to the key for each S3 PUT action, but this doesn’t seem possible if the output of a Save action is the entire path unless I am missing something?