Convert application/octet-stream to PDF

zeerodger27
Tera Contributor

On the case record we have attachment icon, and while preview the attachment it is showing an error but I want to preview the file before downloading is there any possibility?

 

In the attachment table, the file content type is application/octet-stream

 

zeerodger27_0-1744811640509.png

 

Can we change the content type to pdf?

 

1 ACCEPTED SOLUTION

Hello @zeerodger27 ,

 

Please submit a case on Now Support. There is either something wrong with ServiceNow's MIME type detection, or some of the PDFs that you are uploading have an improper internal format that prevents them from being recognized as PDF files.

 

Regards,

Robert

View solution in original post

9 REPLIES 9

Hello @zeerodger27 ,

 

Ok, then you can change the Content Type for this file in the sys_attachment table to "application/pdf" and the preview will work.

 

Regards,

Robert

Yes, it is working but for new attachments can we change content type by using server script or suggest me the best way to do this

Hello @zeerodger27 ,

 

I had assumed that this issue was only related to this one particular PDF file.

 

Or is it happening for all PDFs that are being attached? If so then something must be broken in your instance and you would have to open a Now Support case. I have tested in an OOTB instance that PDF files attached to Cases will correctly be recognized as "application/pdf" in the attachment table.

 

Regards,

Robert

Hi @Robert H,

 

For some PDF files it was recognized as "application/pdf" but for some files it is "application/octet-stream" and I have written before business rule to change the content_type as below:

if(current.table_name == 'custom_case_table_name' && current.content_type == 'application/octect-stream'&&(current.file_name.endsWith('.pdf')|| current.file_name.endsWith('.PDF'))){
        current.content_type = 'application/pdf';
    }

But it is not updating the content_type. Any suggestions?

Hello @zeerodger27 ,

 

Please submit a case on Now Support. There is either something wrong with ServiceNow's MIME type detection, or some of the PDFs that you are uploading have an improper internal format that prevents them from being recognized as PDF files.

 

Regards,

Robert