Retrieve mime/ContentType of previously uploaded document - Forum - Rollbase - Progress Community

Retrieve mime/ContentType of previously uploaded document

 Forum

Retrieve mime/ContentType of previously uploaded document

This question is answered
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
 
Verified Answer
  • 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
  • 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

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