Hi folks
How do I access the filename and MIME type of an attachment in CloudCode?
In the App / Runtime I can call getFilename() on an attachment, and based on the file extension I can assume the MIME Type, but I cannot do this in CC for some reason
getFilename()
@forumfred I had the same issue, however, I was able to extract it from the attachment URL by using RegEx in CloudCode:
function getFileName(attachment: Attachment): string { const regex = /https:\/\/\S+\/(\S+)\?\S+/gm; const results = regex.exec(attachment.url()); console.log(`Results ${JSON.stringify(results)}`); return decodeURI(results[1]); }
I hope that helps.