Attachment & image from public notes is uploaded to S3 but not able to stream and attach it to ticket

We are working on a ticket to move attachment in public notes in FS to ticket created in FD. We were successfully upload attachment & image to S3 from FS but facing issues while stream and attach it to newly created FD ticket.

Here is the community topic what we referred and tried

Creating tickets with attachments using serverless apps

Here is the code

var fields = {
‘email’: ‘email@yourdomain.com’,
‘subject’: ‘Ticket subject’,
‘description’: ‘Ticket description.’,
‘status’: 2,
‘priority’: 1
}
var headers = {
‘Authorization’: auth,
‘Content-Type’:‘multipart/form-data’
}
unirest.post(URL)
.headers(headers)
.field(fields)
.attach(‘attachments’, ‘https://i.imgur.com/lcB62xb.jpg’)
.attach(‘attachments’, ‘https://gist.githubusercontent.com/hemchander23/6708ad5595dd56ef31087d47d4f96a44/raw/89ab0df9685cac94bbb88e1ebfd3655bcade6c9d/DarkS1E4_Script.txt#’)
.attach(‘attachments’, ‘https://s3.amazonaws.com/cdn.freshservice.com/data/helpdesk/attachments/production/15012576518/original/attchmentforaws.txt?X-Amz-Algorithm=algo&X-Amz-Credential=credential%2F20200804%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200804T062727Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=sign’)
.end(function(response){
// console.log(response);
console.log(response.body)
console.log("Response Status : " + response.status)
// if(response.status == 201){
// console.log("Location Header : "+ response.headers[‘location’])
// }
// else{
// console.log(“X-Request-Id :” + response.headers[‘x-request-id’]);
// }
});

Here is the attachment moving from FS to FD

I guess, system fails reading the file path url

Note : I have modified Algorithm, Credentials and Signature, fyi.

Need your help to attach file and images from s3 to ticket.

Thanks!

Hi @Karuppu_Samy,

Seems like you were able to upload attachements from :freshservice: to S3 but are facing problems in adding them back to :freshdesk:.

But following screenshots suggest you were able to successfully accomplish it. Can you suggest what is the error that you are facing?

Issue in third attachment file did not mention that the file extension name.
Because this is a s3 url like end of with credentials added.

Remaining attachment file URL’s don’t have credentials because these files are added.

Thank you.

Looks like .attach() method is part of unirest library.

So Ideally it’s not the system failing in reading the path, but unirest package itself expects the file name,

So since the url given as an argument to the 3rd attachment has query params that unirest’s attach method treats it to be a filename.

2 Likes

Hi @Saif,
I also tried the same, the attachments are uploading but the extension type is unknown (i.e., .txt, .png, etc) as shown in the above screenshot raised by @Karuppu_Samy

and as you mentioned I have passed the name as “attachments” and path as “s3 link” but taking the name from the path. How I can specify what type of file that is uploaded?

-Soujanya.