How to determine multipart/form-data filetypes using Ruby? -
i'm using griddler gem in rails 3.2 app handle incoming emails attachments.
the documentation indicates attached files multipart/form-data files.
is there easy ruby way interrogate these files , determine filetype? need handle different filetypes using different methods.
according rails guide under section 5 'uploading files'
the object in params hash instance of subclass of io. depending on size of uploaded file may in fact stringio or instance of file backed temporary file. in both cases object have original_filename attribute containing name file had on user’s computer , content_type attribute containing mime type of uploaded file.
so interrogate uploaded_io.content_type
, use different methods work whatever content_type
is.
hope gets started in right direction
Comments
Post a Comment