# Trouble to set file metadata

**URL:** <https://community.transloadit.com/t/trouble-to-set-file-metadata/14812>\
**Category:** Uppy\
**Created:** [January 14, 2019, 2:03pm UTC](https://community.transloadit.com/t/trouble-to-set-file-metadata/14812 "2019-01-14T14:03:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dersar00](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@dersar00](https://community.transloadit.com/u/dersar00)\
**Post date:** [January 14, 2019, 2:03pm UTC](https://community.transloadit.com/t/trouble-to-set-file-metadata/14812/1 "2019-01-14T14:03:01Z")

</div>

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

```auto
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;

```

---

<div class="post-metadata">

**Author:** ![ajkachnic](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/ajkachnic/32/260_2.png) [@ajkachnic](https://community.transloadit.com/u/ajkachnic)\
**Post date:** [July 13, 2020, 1:23pm UTC](https://community.transloadit.com/t/trouble-to-set-file-metadata/14812/2 "2020-07-13T13:23:26Z")

</div>

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' })`](https://uppy.io/docs/uppy/#uppy-setMeta-data) — set or update meta for all files.
> 2. [`uppy.setFileMeta('myfileID', { resize: 1500 })`](https://uppy.io/docs/uppy/#uppy-setFileMeta-fileID-data) — set or update meta for specific file.

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

```javascript
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
