Is there any way to find MIME type mismatch files in ServiceNow?

Sumanth16
Kilo Patron

Hi ,

 

In ServiceNow is there any way to find MIME type mismatch files from sys_attachment table by scripting?

7 REPLIES 7

Bhawana Upreti
Tera Guru

Hello,

Please see this documentation:

This property must be set to activate MIME type checking for uploads (All version Eureka and up). Enables (true) or disables (false) mime type validation for file attachments. File extensions configured via glide.attachment.extensions are checked for MIME type during upload.

https://docs.servicenow.com/bundle/jakarta-platform-administration/page/administer/security/reference/r_GeneralSecuritySettings.html

 https://docs.servicenow.com/bundle/jakarta-platform-administration/page/administer/security/concept/c_HighSecuritySettings.html

 

Thanks.

Sumanth16
Kilo Patron

Thanks Bhawana for your response 

We have  300k+ attachments on sys_attachment table,from there i need to find MIME type attachments.Is there any way to do that? 

Can you help me with this

 

 

The attachments that are allowed into Service Now are determined by the System property - security- glide.attachment.extensions - if this property is blank, that means all types of attachments are allowed in the system.

 MIME Types List

var attach = new GlideRecord('sys_attachment');

attach.addQuery('table_sys_id',current.sys_id);

attach.query();

if(attach.next()){//use `while` if dealing with multiple attachments

  if(attach.getValue('file_name').indexOf('pdf') != -1{//meaning if you can find a file with pdf extension

  //do something

  }

}

If the response is useful, mark the answer correct and helpful. 

Thanks.

Sumanth16
Kilo Patron

How to check if the file is of MIME type inside this if loop?