Question on this thread - related to attachments - specifically - sending photo - image attachments - Yurii's example above shows this processing for images (i understand the logic) but...
//Here you can specify needed fileContent.
var fileContent = 'Hi';
//where "testFileName.txt" is your attach file name.
var fileName = 'ZZZ.txt';
var blob = new Blob([fileContent], { type: "text/xml"});
var formData = new FormData();
formData.append("files[" + fileName + "]", blob);
// now the question - for sending an image - what's the type?? and what's the filecontent.
Specifically - I have images stored in a collection called 'attachments' - the image is stored in a column called 'sphotoorother' - and it begins with (first 50 or so characters - example):
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAA
For purposes of sending this via sendGrid - do I tell it the type is ''image/jpeg' ?' ...
for fileContent - do I take the entire image stored in the column where I have my image stored - and load it here - or do I strip off the header (the "data:image/jpeg:base64,/" in my example from above...?
to I create a filename - say what it was called originally plus the implied extension - so say 384310.jpeg - and use that in the formData append statement above where fileName is shown ???
Thanks!
Bruce