Uppy: when using the dashboard and OnbeforeUpload, I click on send, it sends, but the behavior is not as expected. Length undefined error

Created on 23 Jul 2020  路  2Comments  路  Source: transloadit/uppy

I am using a dashBoard in my project with the OnbeforeUpload option, but when I click on send, it brings me a length error and does not bring me the statusBar

My code is like this

const beforeUpload = (files: any) => {
      const updatedFiles = {};
      Object.keys(files).forEach(fileID => {
        this.anexoMetadata.idTipo = this.tipoDocumento.value.id;
        this.anexoMetadata.sigiloso = this.sigiloso.value;

        updatedFiles[fileID] = {
          ...files[fileID],

          meta: files[fileID] = this.anexoMetadata,
        };
      });

      return updatedFiles;
    };

my dash

uppy.use(Dashboard, {
      inline: true,
      replaceTargetContent: true,
      height: 200,
      width: 413,
      note: 'Somente imagens e arquivos (PDF) de at茅 2 MB',
      target: '#dash-drag-drop',
      showProgressDetails: true,
      browserBackButtonClose: true,
      disablePageScrollWhenModalOpen: false,
      showLinkToFileUploadResult: false,
    });

When I use it without onBeforeUpload, it works but can't find my files.

Question

Most helpful comment

damn, thank you very much!

All 2 comments

The Dashboard uses a file's meta.name for rendering. This line is probably overwriting meta so that the file name is not there anymore:

          meta: files[fileID] = this.anexoMetadata,

(Also, that files[fileID] assignment seems wrong 馃槃 )

This should work instead:

meta: {
  ...files[fileID],
  ...this.anexoMetadata
}

damn, thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aleccool213 picture aleccool213  路  3Comments

hikurangi picture hikurangi  路  4Comments

quetzyg picture quetzyg  路  3Comments

eltercero picture eltercero  路  4Comments

evanoberholster picture evanoberholster  路  3Comments