feat: add bmp support for analyze page (#672)

This commit is contained in:
stew-ro 2020-10-30 17:56:03 -07:00 коммит произвёл GitHub
Родитель b0404c6276
Коммит 3485d33eca
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -103,7 +103,7 @@ def getArguments(argv):
for opt, arg in opts:
if opt == '-t':
if arg not in ('application/pdf', 'image/jpeg', 'image/png', 'image/tiff'):
if arg not in ('application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'image/bmp'):
print('Type ' + file_type + ' not supported')
sys.exit()
else:
@ -131,6 +131,8 @@ def inferrType(input_file):
return 'application/pdf'
elif file_extension == '.jpeg':
return 'image/jpeg'
elif file_extension == '.bmp':
return 'image/bmp'
elif file_extension == '.png':
return 'image/png'
elif file_extension == '.tiff':

Просмотреть файл

@ -327,7 +327,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
<input
aria-hidden="true"
type="file"
accept="application/pdf, image/jpeg, image/png, image/tiff"
accept="application/pdf, image/jpeg, image/png, image/tiff, image/bmp"
id="hiddenInputFile"
ref={this.fileInput}
onChange={this.handleFileChange}
@ -493,7 +493,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
private getFileFromURL = () => {
this.setState({ isFetching: true });
fetch(this.state.inputedFileURL, { headers: { Accept: "application/pdf, image/jpeg, image/png, image/tiff" } })
fetch(this.state.inputedFileURL, { headers: { Accept: "application/pdf, image/jpeg, image/png, image/tiff, image/bmp" } })
.then((response) => {
if (!response.ok) {
this.setState({
@ -506,7 +506,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
return;
}
const contentType = response.headers.get("Content-Type");
if (!["application/pdf", "image/jpeg", "image/png", "image/tiff"].includes(contentType)) {
if (!["application/pdf", "image/jpeg", "image/png", "image/tiff", "image/bmp"].includes(contentType)) {
this.setState({
isFetching: false,
shouldShowAlert: true,
@ -857,6 +857,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
switch (file.type) {
case "image/jpeg":
case "image/png":
case "image/bmp":
this.loadImageFile(file);
break;
@ -874,7 +875,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
imageUri: "",
shouldShowAlert: true,
alertTitle: "Not supported file type",
alertMessage: "Sorry, we currently only support JPG/PNG/PDF files.",
alertMessage: "Sorry, we currently only support JPG/PNG/PDF/BMP files.",
});
break;
}