Created
May 15, 2017 20:49
-
-
Save psyked/a021bf7bc4c40a9c646d79daccd7e562 to your computer and use it in GitHub Desktop.
Uploading a file to Trello API with Node.js
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
'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