Trouble Overwriting json with Retool’s S3 Upload Data

Here's your translated question for the Retool forum:


Our service manages some data by uploading metadata.json to Amazon S3. To make this process more convenient, we are using Retool's S3 Resource Query to modify the data. The process of retrieving data works without any issues.

We have set it up so that when we upload a file with the same name as an existing one, it overwrites metadata.json. However, the Upload Data step is not working correctly, and we are seeking advice on resolving this issue.

Our workflow is as follows:

  1. Execute the getMetaData query
  2. Send each field's value to textInput in form1
  3. Modify textInput values
  4. Click the Submit button to execute Run Script
  5. Update data by running setValue on the metadata variable
  6. putMetadata query retrieves metadata.value and executes Upload Data

Has anyone encountered a similar issue or have any suggestions on how to fix this?

const updatedData = {
  recentPlaylistUrl: form1.data.recentPlaylistUrl,
  topNotice: form1.data.topNotice,
  topNoticeMobile: form1.data.topNoticeMobile
};

metadata.setValue(updatedData)

putMetadata.trigger({
  onSuccess: function() {
    utils.showNotification({ title: "Success", message: "metadata.json update success", type: "success" });
  }  
});

@DOS,
I can try to help you debug this!
There might be some timing issues at play here. Instead of running this all in one script, can you put it in a separate query that runs on form submit? And then in the success handler of that to run the putMetadata:

Here's the trigger to run it on form submit:

Here's the updateMetadatq query:

Here's its success handler

Then you can also add a success handler to your putMetadata query for the notification:

I think this should work!

Hey @DOS,
Just checking in to see if my suggestion worked for you.