Last active
October 25, 2022 16:50
-
-
Save bryanbuchanan/a14cf11853322a5d4219e98b044ea853 to your computer and use it in GitHub Desktop.
Make private Trello board attachments publicly-available. https://glitch.com/edit/#!/private-trello-attachment-proxy
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
require('dotenv').config() | |
const express = require('express') | |
const fetch = require('node-fetch') | |
const app = express() | |
app.use('/', async (req, res) => { | |
// Attachment URL | |
const attachmentURL = "https://trello.com/1/cards/5e65954f0f343116e999658f/attachments/5e67a146876719748d64057b/previews/5e67a147876719748d6405ae/download" | |
// Add auth headers and request image | |
const image = await fetch(attachmentURL, { | |
method: "GET", | |
headers: { | |
Authorization: `OAuth oauth_consumer_key="${process.env.TRELLO_KEY}", oauth_token="${process.env.TRELLO_TOKEN}"`, | |
}, | |
}) | |
const buffer = await image.buffer() | |
// Set response headers | |
res.setHeader('content-type', image.headers.get('content-type')) | |
res.setHeader('content-length', image.headers.get('content-length')) | |
// Send file | |
res.send(buffer) | |
}) | |
app.listen(3000, '0.0.0.0') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment