In my retool app, I need to fetch a file from a url, and then POST it to an API. This is how it should work:
The user clicks a button
A JS query gets triggered that does a bunch of housekeeping operations (unrelated). Then:
Fetches a file from a URL. The response has the schema {name, type, sizeBytes, base64Data}
Inside the same JS query, I need to post this file to another API that expects a multipart, binary file. This POST needs the filename as a URL parameter called 'title' and the file as multipart form-data under the 'file' key.
I'm struggling with step 4. I don't know how to go from the file I fetch to the file format that I need to pass to the additional scope of this resource query.
If you can, I'd look at doing the file actions inside a workflow and then calling it. That would likely be cleaner than passing the data between queries inside the app.
However, I think it should be workable inside the app directly. My first recommendation is that if you have an existing form which is doing this to test it with the browser tools open and look at the request which is sent to capture the format. Its a bit difficult to track down anymore, but there are various posts on what the raw format should look like, for example Multipart formposts - everything curl
I think in the outgoing call to send the data, you'll need to set a raw body instead of parameters, then generate the expected text (with the file contents encoded inline). Note the content-type and boundary as described in the link above.
That said, I haven't tried this in Retool, so some trial and error will be needed.