How to create a new blob from attachment.contentUrl on ZAF | Community
Skip to main content

How to create a new blob from attachment.contentUrl on ZAF

  • May 25, 2021
  • 1 reply
  • 0 views

Hi everyone,

I was trying to use comment.attachments() to get the attachment file from the comment, however it doesn't return the real File, it's just return the details of the attached file.

So I am thinking to create a new File by making a new blob file from attachment.contentUrl(), but I can't get it since I got CORS error when I am trying to get it using the fetch function.

This is my code:

this.ticketObj = await parentClient.get('ticket')
const attachmentObject = this.ticketObj.ticket.comment.attachments
const blobFile = await fetch(attachmentObject[0].contentUrl).then(r => r.blob())
const uploadFile = new File([blobFile], attachmentObject[0].filename, { type: attachmentObject[0].contentType })
 
I got the CORS error on the blobFile.
 
Any idea what I am missing?
 
Thank You.
This topic has been closed for replies.

1 reply

Cheeny
  • June 20, 2021

Hi avdnowhere,

We suggest that you check How can I troubleshoot CORS? as a guide in troubleshooting CORS errors.

All the best!