Created
January 16, 2018 21:16
-
-
Save tonyspiro/3d1484f4a130e972ddd1bcfc5bab206b to your computer and use it in GitHub Desktop.
Cosmic JS NPM module - Add Media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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