Retrieve mime/ContentType of previously uploaded document

Posted by stephen.vanrooyen on 08-Feb-2017 02:16

Hi Guys,
 
Is there a way of retrieving the MIME/contentType of a previously uploaded document.
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

Posted by Nitin Kumar Singh on 10-Feb-2017 05:02

Hi Stephen,

There is no standard way of doing this but maybe below solution would suffice for you. For file upload field we save some properties related to uploaded file in database including the property: 'contentType'

Attached is a sample code using Server Side APIs :

Replace 'TextFile' with integration name of file upload field and 'Key' with integration name of Object.

var rs = rbv_api.selectValue("SELECT TextFile FROM Key WHERE ID = ?", {!id});
var rs1 = rs.split("\n");
var rs2 = rs1[3].split("=");
rbv_api.println(rs2[1]);

The select query returns something like this; from which value "contentType=text/plain" can be extracted.

#Fri Feb 03 17:51:22 IST 2017
fileSize=540
origFileName=iLinks.txt
contentType=text/plain
fileName=75\\tmp_1735644164307551290.txt

Thanks, Nitin

All Replies

Posted by Nitin Kumar Singh on 10-Feb-2017 05:02

Hi Stephen,

There is no standard way of doing this but maybe below solution would suffice for you. For file upload field we save some properties related to uploaded file in database including the property: 'contentType'

Attached is a sample code using Server Side APIs :

Replace 'TextFile' with integration name of file upload field and 'Key' with integration name of Object.

var rs = rbv_api.selectValue("SELECT TextFile FROM Key WHERE ID = ?", {!id});
var rs1 = rs.split("\n");
var rs2 = rs1[3].split("=");
rbv_api.println(rs2[1]);

The select query returns something like this; from which value "contentType=text/plain" can be extracted.

#Fri Feb 03 17:51:22 IST 2017
fileSize=540
origFileName=iLinks.txt
contentType=text/plain
fileName=75\\tmp_1735644164307551290.txt

Thanks, Nitin

Posted by stephen.vanrooyen on 13-Feb-2017 03:26

Hi Nitin,
 
Thanx for the solution, was really helpful.
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

This thread is closed