Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Created January 16, 2018 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyspiro/3d1484f4a130e972ddd1bcfc5bab206b to your computer and use it in GitHub Desktop.
Save tonyspiro/3d1484f4a130e972ddd1bcfc5bab206b to your computer and use it in GitHub Desktop.
Cosmic JS NPM module - Add Media
const bucket = Cosmic.bucket({
slug: 'bucket-slug',
write_key: ''
})
bucket.addMedia({
media: '<FILE_DATA>',
folder: 'your-folder-slug',
metadata: {
caption: 'Beautiful picture of the beach',
credit: 'Tyler Jackson'
}
}).then(data => {
console.log(data)
}).catch(err => {
console.log(err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment