Discussions
Custom Messaging: Sending Messages with Attachments... but, how?
I have successfully obtained my uploadSignedUri and I now want to upload my attachment. How? the link in the documentation takes you to the "Generate Upload URI" so that's no help. I understand that to upload the attachment i POST multipart/formdata containing the attachment in the mediaFile field. when i do that, i get 400 "the request was rejected because no multipart boundary was found".
I have some working code to copy by Andrew Prokop and my non working code it very similar to his. He's using axios, which I believe abstracts some of the handling of formdata and so my pure javascript code is probably missing some details here - what details? this call appears to be completely undocumented.
I have tried a number of variations in the call and only succeeded in changing the error message.
my code runs client side and i've just picked the file with: x = showOpenFilePicker() off the local disk. i then have: x[0].getFile().then( f=>ulFile( text, f)); and (skipping obtaining the upload URL) in ulFile I have:
let formdata = new FormData();
formdata.append( 'mediaFile', f);
let ulOpts = {
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
'Accept': 'application/json'
},
body: formdata
}
console.log( "Media Upload to: " + ulObj.uploadSignedUri);
console.log( "Media Upload opts: " + JSON.stringify( ulOpts, undefined, 4));
fetch( ulObj.uploadSignedUri, ulOpts).then( r=> r.json()).then( o=> ulFile3( o));
Any ideas??