Attachment - File Type/Extension

0 votes

For attachments that are uploaded, how can I get the file extension (PDF, jpg, tif, etc...)? I only see these attributes on OneSpanAPIOjbects.AttachmentRequirement:

   = data;
            this.description = description;
   = id;
   = name;
            this.required = required;
            this.comment = comment;
            this.status = status;

I am saving the document to a ContentVersion and we have been setting:

            ContentVersion.PathOnClient = documentName + '.pdf'

I need to make this dynamic with attachments.

Approved Answer

Reply to: Attachment - File Type/Extension

0 votes

Hi Peter,


You can extend the API object in below way:

    public class AttachmentRequirement
        public string name {get;set;}
        public string description {get;set;}
        public string status {get;set;}
        public string id {get;set;}
        public string comment {get;set;}
        public boolean required {get;set;}
        public List<AttachmentFile> files {get;set;} 

   public class AttachmentFile
        public Long id {get;set;}
        public Long insertDate {get;set;}
        public string name {get;set;}
        public Boolean preview {get;set;}    


In real practice, if the file.size() > 1, the downloaded file is a zip file. There's a package/account level setting "maxAttachmentFiles" where you can force signers to upload a single file per attachment requirement:

  "settings": {
    "ceremony": {
      "maxAttachmentFiles": 1


And if the AttachmentRequirement.status == 'COMPLETE' && file.size() == 1, you can retrieve the uploaded file's extension by:'.'))


On top of that, you can also limit the allowed uploaded file type, it's documented in this dev blog:



Duo Liang OneSpan Evangelism and Partner Integrations Developer

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off