Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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