In my experience, there’s no issue with how the $SESSION variables are accessed in server connects. In a NodeJS environment. Are those quotes “” part of the session variable name ??
Yes, the quotes around the session variable are just how my browser’s web inspector displays it. I use Safari, but it’s the same for Chrome.
So I have ditched the idea of using a session variable, but I really don’t know which input I can use as my key. Using the $_GET variable ‘name’ correctly uploads the initial file name, but I want to change this to something more controllable.
Unfortunately the tutorial for using this uploader is quite basic and doesn’t cover what I need. If anyone knows any tricks I can use, it would be welcome. Thanks.
The session on the client is different from the session on the server. The session value you are showing in the dev console is not available to the s3 action in the server.
Thanks Ken. So setting a session on the server would be available to use with S3?
I was thinking that since the original name of the file is uploaded via $_GET, I could use the same idea for another variable eg. ‘new_filename’. However, I’m not sure where the best place to define this is.
Now that I realise there’s a difference between browser and server side sessions (I’m sure I’m not the first person confused by this nomenclature), I’m starting to wonder if I can actually achieve my objective.
Sure, I’ve been able to set a session variable on the server. And this does work with S3. However the value I want to use is accessed in the App Connect panel and I can’t find any references which match the current interface about overriding a server side session variable in App Connect.
So my question is this. Has anyone been able to change the name of files they upload to an S3 bucket? If so, how did you achieve this? Thanks in advance.
(I’m sure I’m not the first person confused by this nomenclature.)
Definitely include me in that group!
You can use any dynamic data you would like in naming the file. If the name is provided by the user, then your GET variable is an option, or you can use a form to POST data to the server.
Unfortunately I am yet to find a workable solution - I’m sure I’m missing something obvious! To reiterate, I am simply trying to change the name of the uploaded file before it gets sent to my S3 bucket. I initially tried to use a session, but have now tried using a GET variable.
So when I use ‘$_GET.name’ in the key path, it uploads the current filename. So it should follow that I can use a different GET variable - in this case ‘$_GET.filenamenew’. However, I don’t know how or where to define this. Traditionally I would add a ‘?filenamenew="xyz.jpg’ to the url, but I am unsure how to insert a GET variable inside the JSON of the sign upload_categories.php file.
Hi Pete,
Had exactly the same outcome with node.js,
As it seems s3 upload defaults to overwriting an existing file with the same name,
being able to rename the file would be very helpful…Sorry I can’t help
FYI I was able to resolve the problem by using the old file upload method - where the file is uploaded to the server first, before transferring to the bucket. This method has provision to rename the file.
If only the new method included the same functionality…
In case anyone else is dealing with this, I was able to change the filename using the following method:
Custom PHP API.
Set a Wappler Value to the data of that API
Set the "key" field to that Wappler Value.
MORE DETAILS:
I made my own PHP api that sends me a random number (but this could be anything, even a value or form field that your user just submitted and this PHP file grabs it). Using the API I get the data.
For my case the php file basically says:
<?php echo rand(10000,99999); ?>
Then I "Set Value" on that data and assign it to the "RandomNumber" value.
Then, in the "Key" field of the S3 upload I utilize that value.
As you can see below, I actually use another value called "FileNameSetter" because in that value I hash the file name with a sha256, add a timestamp, and then a five digit random number.
Am I a little obsessed about having unique file names? Yes. That's okay