Trouble to set file metadata

Hello there!
When I try to set metadata to every file I upload, I didn’t got expected result, my code below

const React = require('react')
const Uppy = require('@uppy/core')
const Tus = require('@uppy/tus')
const GoogleDrive = require('@uppy/google-drive')
const Instagram = require('@uppy/instagram')
const Dropbox = require('@uppy/dropbox')
const { Dashboard } = require('@uppy/react')

export class UppyDashboard extends React.Component {
  constructor (props) {
    super(props)
  }

  componentWillMount () {
    this.uppy = new Uppy({ id: 'uppy', autoProceed: true, debug: true })
      .use(Tus, { endpoint: '//my.test/files/' })
      .use(GoogleDrive, { serverUrl: 'http://localhost:3020' })
      .use(Instagram, { serverUrl: 'http://localhost:3020' })
      .use(Dropbox, { serverUrl: 'http://localhost:3020' })


    this.uppy.on('upload', (data) => {
      let IDs = data.fileIDs;
      uppy = this.uppy;
      
      console.log(IDs);

      IDs.forEach(function (id, index) {
        console.log(id);
        
        uppy.setFileMeta(id, { mymetadata: "hooraay" });  
      });
      
    });
  }

  componentWillUnmount () {
    this.uppy.close()
  }

  render () {
    return (
      <div id="UppyDashboard">
        <Dashboard
          uppy={this.uppy}
          plugins={['GoogleDrive', 'Instagram', 'Dropbox']}
        />
      </div>
    )
  }
}

export default UppyDashboard;

I know this is an old question, but I might be able to help still.

I can’t be too sure of what your specific issue is, but I may still have a solution for you.

If you need to apply meta data to every file, you should be using setMeta. Here’s a snippet from the docs explaining this:

This global metadata is added to each file in Uppy. It can be modified by two methods:

  1. uppy.setMeta({ username: 'Peter' }) — set or update meta for all files.
  2. uppy.setFileMeta('myfileID', { resize: 1500 }) — set or update meta for specific file.

You’d need to update the on('upload') method like so:

this.uppy.on('upload', (data) => {
      uppy = this.uppy;
      
      console.log(IDs);
      uppy.setMeta({ mymetadata: "hooraay" });  
});

That should resolve the issue and shorten the code. Let me know if you have any further questions or problems

- Andrew