Using Files Uploaded to Retool Storage

I uploaded a CSV file to retool storage and now I want to send that file to an endpoint (specifically OpenAI's /file endpoint), but I don't know how to actually use any of these files. That is, if I want to send the actual file of something previously uploaded to retool storage, what is my dynamic value in the query?

I tried creating a query to download the file I want and referencing that {{downloadQuery.data}}, but that just downloads the file locally when I run the query.

Can retool pass actual files from retool storage to queries?

Yes! You can fetch files as a Retool Storage query as described here. As for sending the file with an api, you could follow this

1 Like

Those docs show you how to send the file as base64. This doesn’t work with the openAI /files endpoint. I’ve tried it. It needs you to reference basically the local file and send it.

Are you using the OpenAI's file upload endpoint as part of a RestAPI resource? Ideally you should be able to simply pass the entire file object as part of the file type in the request ie. {{retoolStorageQuery.data}} into the body as Form Data file field. Something like this (see screenshot). Let me know if that doesn't work?

Yes...that's what I'm doing, but using the "prefilled" retool API connection to the openAI API. So, I've already added the file to retool storage. How do I reference a previously uploaded file? Do I need to have a query to get the file? Is that the download call to retool storage?

One thing that's different on your last screenshot is that the body is Form Data. That's not an option from what I'm seeing. And I know that you need to send the data to openAI as "multipart/form-data" for the /files endpoint.

Something is not lining up.

Ah...so if I just use a straight REST API call and not the built into Retool openAI query options, this all works just fine. I can even use the value of a file upload component and skip the retool storage.

So, I'm thinking there isn't something quite right with how Retool's implementation works.

This setup worked perfectly, but I'd think I should be able to do this with Retools implementation, but it definite doesn't work and I'm guessing because the /files endpoint isn't using the right Content-Type and there's no way to manually change it.

Yes. This is unfortunately broken at the moment. Apologies for the confusion and friction here. We are aware and will prioritize a fix. The RestAPI resource is a valid workaround for the time being.

1 Like