javascriptfrontenduppy

How to add custom post fields in Uppy XHR request?


Used Uppy XHR Upload. Docs: https://uppy.io/docs/xhr-upload/ How to add custom post fields in Uppy XHR request?

My params are:

endpoint: '/?test1=test2',
formData: true,
method: 'post',
fieldName: 'files[]',
// metaFields: [{ cmd: 'test1', name2: 'test2' }],
metaFields: [
  ['command', 'myvalue']
]

It is need to add my additional "post" fields for server, but test1=test2 are "get" params, 'command' and 'myvalue' - params without values (only keys are send via XHR). How to add "post" params and it`s values in Uppy XHR (or other uppy plugins, if in XHR not available)?


Solution

  • You should use meta in Uppy.Core to pass post parameters with values. Eg:

    Uppy.Core({
    
            meta: {
                professional_id: professional_id,
                client_id: client_id,
                post_id: post_id,
                proposal_id: proposal_id,
                folder_id: folder_id,
                version_no: version_no
            },