UploadInput

An upload input lets users upload a single file, or multiple files, within a form. See usage guidelines for more info.

Actual network request can be performed by the API library of your choice (e.g. fetch or axios). Perform the form submission for each file individually inside onFileUpload(formData) and return a Promise with the result that must contain an id and optionally url, error fields.

Deletion is performed via onDeleteFile(id), that receives the id of the file and can perform the API request, as long as it returns a Promise<void>.

If you need to override the default link behaviour for existing files, provide an onDownload(file: UploadedFile) callback.

receipt failed.png
Error message from API

An example for an actual onUploadFile() callback:

const onUploadFile = (formData) => {

  const additionalData = {
    activityId: '12345',
    profileId: 6789,
    ...
  };

  const customHeaders = {
    'Accept-language': 'en',
    ...
  };

  Object.keys(additionalData).forEach((key) => formData.append(key, additionalData[key]));

  return fetch(`v2/someApi/someEndpoint`, {
    method: 'POST',
    body: formData,
    headers: customHeaders
    credentials: 'include',
  })
    .then((response) => {
      if (!response.ok) {
        const error = new Error(response.statusText);
        error.status = response.status;
        throw error;
      }
      return response.json();
    })
    .catch((e) => {
      throw e;
    });
};
Edit these docs on Github