How to specify folder when using Uppy with Tus?

Started by empz2 replies172 views
empzOriginal post
#1

I’m setting up Uppy.js (React) with the Supabase TUS server. It’s working but file ends up in the root of the storage. I want to be able to specify a folder (based on the current user id) so that all file uploads for a particular user are always into its own folder.

Is this possible? If so, how?

MerlijnTransloadit team
#2

Supabase uses tus-node-server which does support that but it’s a server-side feature so I think you have to look at their docs to figure this out, not ours.

empzAccepted answer
#3

Found it.

It’s needed to set the right objectName within the Uppy file metadata on file added event.

.on("file-added", async (file) => {
            // Attach metadata to each file, including bucket name and content type
            file.meta = {
              ...file.meta,
              bucketName, // Bucket specified by the user of the hook
              objectName: `${someParentFolder}/${file.name}`, // Use file name as object name
              contentType: file.type, // Set content type based on file MIME type
            };