최근 검색


최근 검색 없음

avdnowhere's Avatar

avdnowhere

가입한 날짜: 2021년 10월 16일

·

마지막 활동: 2023년 12월 27일

팔로잉

0

팔로워

0

총 활동 수

4

투표 수

0

플랜 수

2

활동 개요

님의 최근 활동 avdnowhere

avdnowhere님이 에 게시물을 만듦

게시물 Developer - Zendesk Apps Framework (ZAF)

Hi everyone,

I have an attachment on internal note and I want to fetch it from my custom app.

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 (like filename, contentType, contentUrl, thumbnailUrl, and token).

So I am thinking to create a new File by making a new blob from attachment.contentUrl(), but I can't get it due to CORS error when I am trying to get the attached file 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()) // I got CORS error on this line
const uploadFile = new File([blobFile], attachmentObject[0].filename, { type: attachmentObject[0].contentType })
 
I got the CORS error on the blobFile line.
 
Anyway, the value for attachmentObject[0].contentUrl is something like "https://xxxxx.zendesk.com/attachments/token/PppppmfyyOmjtyXbXxxxXXxxx/?name=abc.png"
 
And the CORS error shows "Access to fetch at 'https://xxxxx.zendesk.com/attachments/token/PppppmfyyOmjtyXbXxxxXXxxx/?name=abc.png' from origin 'https://333999.apps.zdusercontent.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
 
Any idea what am I missing here?
 
Thank You.

2021년 5월 27일에 게시됨 · avdnowhere

0

팔로워

3

투표 수

1

댓글


avdnowhere님이 에 게시물을 만듦

게시물 Developer - Zendesk Apps Framework (ZAF)

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.

2021년 5월 25일에 게시됨 · avdnowhere

0

팔로워

3

투표 수

1

댓글