mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Merge pull request #67 from ascribe/AD-1362-implement-portfolioreview-judging-flow
Use mime types for <input>'s accept property
This commit is contained in:
commit
33db8e2cbe
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import MimeTypes from '../../constants/mime_types';
|
||||
|
||||
export const formSubmissionValidation = {
|
||||
/**
|
||||
* Returns a boolean if there has been at least one file uploaded
|
||||
@ -73,8 +75,11 @@ export function displayValidProgressFilesFilter(file) {
|
||||
* @return {string} Joined string (comma-separated) of the passed-in array
|
||||
*/
|
||||
export function transformAllowedExtensionsToInputAcceptProp(allowedExtensions) {
|
||||
// add a dot in front of the extension
|
||||
let prefixedAllowedExtensions = allowedExtensions.map((ext) => '.' + ext);
|
||||
// Get the mime type of the extension if it's defined or add a dot in front of the extension
|
||||
// This is important for Safari as it doesn't understand just the extension.
|
||||
let prefixedAllowedExtensions = allowedExtensions.map((ext) => {
|
||||
return MimeTypes[ext] || ('.' + ext);
|
||||
});
|
||||
|
||||
// generate a comma separated list to add them to the DOM element
|
||||
// See: http://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-type-file
|
||||
|
11
js/constants/mime_types.js
Normal file
11
js/constants/mime_types.js
Normal file
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const MimeTypes = {
|
||||
'jpg': 'image/jpeg',
|
||||
'jpeg': 'image/jpeg',
|
||||
'gif': 'image/gif',
|
||||
'pdf': 'application/pdf',
|
||||
'png': 'image/png'
|
||||
};
|
||||
|
||||
export default MimeTypes;
|
Loading…
Reference in New Issue
Block a user