ReTool Storage / File Upload / Orphaned Uploads

I am trying to solve the issue of Orphaned Uploads. Let's use the FileDropzone component for my example. I have a form, with fields, and then I want the user to be able to add a few documents with the submission. We add the filedropper, and tick the box for "Upload file to Retool Storage"

This works, we drop demo.txt and see it in ReTool storage. What happens now when, oops, the user picked the wrong file. They click clear, and drop a different file. Now the first file is orphaned! Clear did not remove the upload, so now what do we do with that file? Are we supposed to be keeping our own, in-app list of temp uploads and have an additional query to remove uploads?

Or maybe I thought that using another query, we could move the uploads to a folder, but there is no action for move
image

I was hoping for a more intuitive way to manage the files in ReTool storage, and if there is a better way, I would love to hear from the community.

1 Like

Since you posted this, we've added support for folders. You could consider creating a new folder per user, and exposing the list of files within a folder using the get a list of file metadata query, to allow them to delete their files (on which you'd trigger a delete to get rid of said file). Alternatively, even without folders, if you track what files were uploaded by a particular user on a db (eg retooldb), you could still fetch this metadata for the files of interest and allow them to delete from files they uploaded. Would that work for you?

1 Like

Hey, is there a way to create folder programmatically?

Yes. You can use the storage upload query and pass the folder name as a string by choosing the fx option. You can also pass params as usual {{foldernameVar}}. See screenshot where I pass a folder named 'myNewFolder' that did not previously exist. We don't yet allow only creating an empty folder (without a file written) programmatically but hopefully this works? Let me know if not.

1 Like

A post was split to a new topic: Retool Storage: When multiple files selected in fileDropZone, only one file is uploaded