node-trello
node-trello copied to clipboard
add args even with attachment
Without this commit, the filename can't be set to name other than the original file name. But still, there is some issue setting the mimeType.
This seems really shotgunny — in that it seems like you’d accidentally send a bunch of useless stuff (since you’re copying every key over from the arguments). Is there an approach that’s more targeted?
After some trials and errors, it seems the best way is to set the filename with extension and set with attachment. Even though explicitly setting the name and mimeType, Trello won't help me generating an image preview, if my filename is like upload_3456789 instead of image.png with the correct extension.
My situation is, when I did a form upload to my node server with koa-body module, it will generate a filename with random string. If I applied this commit and send the request with,
{
"attachment": file,
"name": "abc.png",
"mimeType": file.type,
}
I can set the display name to abc.png. But it won't, 1. generate an image preview and 2. when downloading the file, it's not abc.png but the random string generated by the module.
My best workaround is renaming the temporary file to abc.png.