fix: Remove application/octet-stream as valid frontend mimetype (#2126)
* Remove application/octet-stream and add explicit extensions * Modify the condition to check for extensions too
This commit is contained in:
parent
fed3774cee
commit
a39f7a4e55
|
@ -1,4 +1,5 @@
|
|||
// @flow
|
||||
import path from "path";
|
||||
import invariant from "invariant";
|
||||
import { find, orderBy, filter, compact, omitBy } from "lodash";
|
||||
import { observable, action, computed, runInAction } from "mobx";
|
||||
|
@ -24,12 +25,13 @@ export default class DocumentsStore extends BaseStore<Document> {
|
|||
|
||||
importFileTypes: string[] = [
|
||||
".md",
|
||||
".doc",
|
||||
".docx",
|
||||
"text/markdown",
|
||||
"text/plain",
|
||||
"text/html",
|
||||
"application/msword",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/octet-stream",
|
||||
];
|
||||
|
||||
constructor(rootStore: RootStore) {
|
||||
|
@ -532,9 +534,14 @@ export default class DocumentsStore extends BaseStore<Document> {
|
|||
options: ImportOptions
|
||||
) => {
|
||||
// file.type can be an empty string sometimes
|
||||
if (file.type && !this.importFileTypes.includes(file.type)) {
|
||||
if (
|
||||
file.type &&
|
||||
!this.importFileTypes.includes(file.type) &&
|
||||
!this.importFileTypes.includes(path.extname(file.name))
|
||||
) {
|
||||
throw new Error(`The selected file type is not supported (${file.type})`);
|
||||
}
|
||||
|
||||
if (file.size > env.MAXIMUM_IMPORT_SIZE) {
|
||||
throw new Error("The selected file was too large to import");
|
||||
}
|
||||
|
|
Reference in New Issue