fix file parsing
This commit is contained in:
parent
70ef8b9eed
commit
3daf0ce214
2 changed files with 10 additions and 16 deletions
|
@ -14,7 +14,7 @@ const publish = require('./publish.js');
|
|||
const createPublishParams = require('./createPublishParams.js');
|
||||
const createThumbnailPublishParams = require('./createThumbnailPublishParams.js');
|
||||
const parsePublishApiRequestBody = require('./parsePublishApiRequestBody.js');
|
||||
const {parsePublishApiRequestFiles} = require('./parsePublishApiRequestFiles.js');
|
||||
const parsePublishApiRequestFiles = require('./parsePublishApiRequestFiles.js');
|
||||
const authenticateUser = require('./authentication.js');
|
||||
|
||||
const CLAIM_TAKEN = 'CLAIM_TAKEN';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const path = require('path');
|
||||
const validateFileTypeAndSize = require('./validateFileTypeAndSize.js');
|
||||
|
||||
const parsePublishApiRequestFiles = ({file}, isUpdate) => {
|
||||
const parsePublishApiRequestFiles = ({file, thumbnail}, isUpdate) => {
|
||||
// make sure a file was provided
|
||||
if (!file && !isUpdate) {
|
||||
throw new Error('no file with key of [file] found in request');
|
||||
|
@ -32,26 +32,20 @@ const parsePublishApiRequestFiles = ({file}, isUpdate) => {
|
|||
// validate the file
|
||||
if (file) validateFileTypeAndSize(file);
|
||||
// return results
|
||||
return {
|
||||
const obj = {
|
||||
fileName : file.name,
|
||||
filePath : file.path,
|
||||
fileExtension: path.extname(file.path),
|
||||
fileType : file.type,
|
||||
};
|
||||
};
|
||||
|
||||
const parsePublishApiRequestThumbnail = ({thumbnail}) => {
|
||||
if (!thumbnail) {
|
||||
return;
|
||||
if (thumbnail) {
|
||||
obj.thumbnailFileName = thumbnail.name;
|
||||
obj.thumbnailFilePath = thumbnail.path;
|
||||
obj.thumbnailFileType = thumbnail.type;
|
||||
}
|
||||
return {
|
||||
thumbnailFileName: thumbnail.name,
|
||||
thumbnailFilePath: thumbnail.path,
|
||||
thumbnailFileType: thumbnail.type,
|
||||
};
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
parsePublishApiRequestFiles,
|
||||
parsePublishApiRequestThumbnail,
|
||||
};
|
||||
module.exports = parsePublishApiRequestFiles;
|
||||
|
|
Loading…
Reference in a new issue