While adding a new card with the trello_client.js library, I want to attach an image or more. The documentation only mentions that fileSource
is "A file".
Data URI didn't work as is, and blobs are usually appended to FormData objects so I'm not sure how to approach this and didn't find working examples.
And is it even possible to attach multiple files along with the card creation, or only later, by separate post
s here?
The Trello API expects either a URL to be attached, or a file encoded as
multi-part/formdata
.I've put together a series of examples on different ways you can attach files to a card using Javascript. You can check it out here: https://glitch.com/~trello-attachments-api. To see the example project running live, click "Preview App."
The client.js library doesn't support attaching file attachments. You'll need to use a standard XHR and FormData object.
Here's some sample code: https://plnkr.co/edit/PjJsfMgJuJaM5A83RAiW
The relevant bits of HTML:
and the javascript: