Skip to content

Commit

Permalink
Analyzing file content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
GribovskyPavel committed Feb 6, 2024
1 parent 2b49be0 commit 0c8e9cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/common/store/job/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getJob, getJobId, getTaskErrorMessage, getTaskResultId, getTaskStatus }
import * as JobService from '../../services/jobService';
import * as FileService from '../../services/fileService';
import { updatePdfFile, storeFile } from '../pdfFiles/actions';
import { uploadLinkAction } from '../pdfLink/actions';
import { setResult } from './result/actions';
import { lockApp, unlockApp } from '../application/actions';
import { getProfile } from './settings/selectors';
Expand Down Expand Up @@ -98,8 +97,10 @@ const uploadPdfFile = createStep('FILE_UPLOAD', 30, async (dispatch, getState) =
dispatch(updatePdfFile(fileDescriptor));
} else {
const link = getFileLink(getState());
uploadLinkAction(link);
const fileDescriptor = await FileService.uploadLink(link);
if (fileDescriptor.contentType !== 'application/pdf') {
throw new Error('Content type is not application/pdf');
}
const blob = await FileService.getFileContent(fileDescriptor.id);
const file = new File([blob], fileDescriptor.fileName);
await dispatch(storeFile(file));
Expand Down
10 changes: 0 additions & 10 deletions src/common/store/pdfLink/actions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { createAction } from 'redux-actions';
import { uploadLink } from '../../services/fileService';

export const setLink = createAction('PDF_LINK_ADD');

export const setError = createAction('PDF_LINK_ERROR');

export const uploadLinkAction = () => {
return async (_dispatch, getState) => {
const { link, error } = getState().pdfLink;
if (!error && link?.length) {
await uploadLink(link);
}
};
};

0 comments on commit 0c8e9cc

Please sign in to comment.