fix update parsing issue
This commit is contained in:
parent
9ba4c4641e
commit
eaab9bb21b
2 changed files with 12 additions and 2 deletions
|
@ -3,7 +3,17 @@ const validateFileTypeAndSize = require('./validateFileTypeAndSize.js');
|
|||
|
||||
const parsePublishApiRequestFiles = ({file, thumbnail}, isUpdate) => {
|
||||
// make sure a file was provided
|
||||
if (!file && !isUpdate) {
|
||||
if (!file) {
|
||||
if (isUpdate) {
|
||||
if (thumbnail) {
|
||||
const obj = {};
|
||||
obj.thumbnailFileName = thumbnail.name;
|
||||
obj.thumbnailFilePath = thumbnail.path;
|
||||
obj.thumbnailFileType = thumbnail.type;
|
||||
return obj;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
throw new Error('no file with key of [file] found in request');
|
||||
}
|
||||
if (!file.path) {
|
||||
|
|
|
@ -66,7 +66,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
|||
|
||||
try {
|
||||
({name, nsfw, license, title, description, thumbnail} = parsePublishApiRequestBody(body));
|
||||
({fileName, filePath, fileExtension, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files));
|
||||
({fileName, filePath, fileExtension, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files, true));
|
||||
({channelName, channelId, channelPassword} = body);
|
||||
} catch (error) {
|
||||
return res.status(400).json({success: false, message: error.message});
|
||||
|
|
Loading…
Reference in a new issue