Trouble to set file metadata


#1

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;