How to upload attachments programmatically for messages and events in Plain.
attachment:create
Creating an upload url
fileName
is the name under which the attachment will appear in the timeline, you can use whichever you wantfileSizeBytes
is the exact size of the attachment in bytes (specifically, 32318
bytes is the size of Bruce’s picture above)c_XXXXXXXXXXXXXXXXXXXXXXXXXX
is the customer id you are uploading the attachment for. Remember to replace this!Uploading the attachment
AttachmentUploadUrl
we created in the previous step we get back 2 fields which are needed to actually upload our attachment:uploadFormUrl
: The URL to which to upload the file touploadFormData
: A list of key, value pairs that have to be included in the data we upload along with the actual file data.multipart/form-data
) with the data contained in uploadFormData
and submit it to the uploadFormUrl
.Here is some example code showing how you would do this in the Browser and from a Node server: bat, bin, chm, com, cpl, crt, exe, hlp, hta, inf, ins, isp, jse, lnk, mdb, msc, msi, msp, mst, pcd, pif, reg, scr, sct, shs, vba, vbe, vbs, wsf, wsh, wsl