Skip to content

Instantly share code, notes, and snippets.

@psyked
Created May 15, 2017 20:49
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 psyked/a021bf7bc4c40a9c646d79daccd7e562 to your computer and use it in GitHub Desktop.
Save psyked/a021bf7bc4c40a9c646d79daccd7e562 to your computer and use it in GitHub Desktop.
Uploading a file to Trello API with Node.js
'use strict'
const fs = require('fs')
const path = require('path')
const Trello = require('node-trello')
const trelloAuth = JSON.parse(fs.readFileSync('trello-credentials.json', 'utf8'))
const t = new Trello(trelloAuth.key, trelloAuth.token)
t.post(`/1/cards/${card.id}/attachments`, {
attachment: fs.createReadStream(path.resolve(__dirname, 'downloads/', file))
}, function (err, attachments) {
if (err) {
console.log(err)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment