clarin-eric / LRSwitchboard

DEPRECATED - Please see https://github.com/clarin-eric/switchboard for latest version - Code Repository for the Language Resources Switchboard of CLARIN
Other
1 stars 0 forks source link

Supported upload mimetypes should not be hardcoded #63

Closed andmor- closed 5 years ago

andmor- commented 5 years ago

Current the mimetypes supported for upload are hardcoded. See: https://github.com/clarin-eric/LRSwitchboard/blob/master/app/back-end/util.js#L66

This raises two problems:

  1. It becomes cumbersome to update this list, requiring a new release
  2. Any file with mimetype outside the list, will default to .txt and will be uploaded as text/plain. This makes it difficult to use Nextcloud's upload filter based on mimetype. The mimetype we want to allow is precisely text/plain, but if a video file is uploaded, it will be uploaded as a .txt and thus defeating the NC filter.

A quick improvement would be to remove or change the default case on L84 to something we want and can block e.g. .mp4

In the long term we want to have this list extracted to a separate text file which is read either at runtime or during startup. The generation of the list must be based on the list of mimetypes supported by the tools.

claus-zinn commented 5 years ago

Put quick improvement in place. Default is now .mp4 unless an acceptable media type is encountered.

andmor- commented 5 years ago

I needed to add (72afa3a) mimetypes for zip files (application/zip). zip mimetype is supported by some tools: WebSty and Topic. See: https://github.com/clarin-eric/LRSwitchboard-rest/blob/master/Registry.js#L1821 This highlights a design problem: to add a new tool (or a new mimetype to an existing tool), both have to be updated: https://github.com/clarin-eric/LRSwitchboard/blob/master/app/back-end/util.js and https://github.com/clarin-eric/LRSwitchboard-rest/blob/master/Registry.js This is less than ideal: defeats the ability to add tools without rebuilding the code and makes the code more error prone, increasing its complexity. Currently it is also not clear why we need function fileExtensionChooser (mimetype) for uploaded files. For now I commit this as a quick fix but we must fix the design problem.

emanueldima commented 5 years ago

Solved in the new Switchboard where the tool registry informs the frontend what media types are accepted.