Restricting mime types

Archived from the Transloadit support forum. Originally posted on January 5, 2012; details may be outdated, see our docs for current behavior. Original thread

I am trying to restrict and upload of resumes to a s3 bucket to .doc and .doc files, also these need to be under 2MB, below is my template but the docx files are caught by FILE_FILTER_DECLINED_FILE, is this possible to achevie using the file filter step?
Regards,
Carl.

{ auth "REDACTED"},
"steps": {
     "files": {
    "robot": "/file/filter",
    "accepts": [
      ["${file.mime}", "regex", "application/msword"],
      ["${file.mime}", "regex", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]
    ],
    "result": true,
    "declines": [
      ["${file.size}", ">", "2097152"]
    ],
    "error_on_decline": true
},
"store":
{ "robot": "/s3/store"
, "bucket": "xxx"
, "key": "xxx"
, "secret": "xxx"
, "acl": "private"
}

} }

I think I have resolved my issue by just interrogating the file.ext, not sure if this is best practise though as I am new to Transloadit and finding my feet at present.

[“${file.ext}”, “=”, “doc”], [“${file.ext}”, “=”, “docx”]

He cmarsay,

the decline step looks fine with the 2MB. It should be the mime type that is problematic.

When you now upload some files with your new conditions, can you check in the json what the actual mime types were that were extracted?

if they seem right I’d like you to attach such a file here so I can debug this.

I first thought it’s the forward slash in the string that is not properly escaped for being handled by the regex, but a small test proved it’s not a problem.

Thank you
Tim

Closing this.