Uppy, uploading additional information

Started by RokasDie1 reply2,263 views
RokasDieOriginal post
#1

Hello,

I have a question from design perspective. I am creating a newsletter template where user would input text and upload a photo. I am using XHRUpload and I want to upload picture together with the text to the same entry in SQL database, for this I need them to be sent together. However, uppy.upload() method can only send picture data to the endpoint. Maybe someone can help here?

Regards,
Rokas

artur
#2

Hi!

Uppy supports sending metadata with the upload, which you’ll then receive on the server: https://uppy.io/docs/uppy/#meta. So you can do something like this:

const uppy = Uppy({...}) // instantiate Uppy
...

function handleUserInputText(text) {
  uppy.setMeta({ userText: text }) // call .setMeta() to set the metadata
}

This metadata will be set to each file you users upload. If you want to specify metadata per individual file, it’s also possible via uppy.setFileMeta('fileID', { userText: text }).

We also have a UI in the Dashboard, where user can edit metadata fields: https://uppy.io/docs/dashboard/#metaFields, and they are also applied per file then.