fixed missing file extension
This commit is contained in:
parent
369399ca98
commit
0142c168ae
2 changed files with 59 additions and 42 deletions
|
@ -5,13 +5,6 @@ const DEFAULT_THUMBNAIL = 'https://spee.ch/assets/img/video_thumb_default.png';
|
||||||
const NO_CHANNEL = 'NO_CHANNEL';
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
const NO_FILE = 'NO_FILE';
|
const NO_FILE = 'NO_FILE';
|
||||||
|
|
||||||
function chooseThumbnail (claimInfo, defaultThumbnail) {
|
|
||||||
if (!claimInfo.thumbnail || claimInfo.thumbnail.trim() === '') {
|
|
||||||
return defaultThumbnail;
|
|
||||||
}
|
|
||||||
return claimInfo.thumbnail;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getClaimId (channelName, channelId, name, claimId) {
|
getClaimId (channelName, channelId, name, claimId) {
|
||||||
if (channelName) {
|
if (channelName) {
|
||||||
|
@ -82,7 +75,7 @@ module.exports = {
|
||||||
element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`;
|
element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`;
|
||||||
element['showUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}`;
|
element['showUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}`;
|
||||||
element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`;
|
element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`;
|
||||||
element['thumbnail'] = chooseThumbnail(element, DEFAULT_THUMBNAIL);
|
element['thumbnail'] = module.exports.chooseThumbnail(element, DEFAULT_THUMBNAIL);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
resolve({
|
resolve({
|
||||||
|
@ -112,8 +105,32 @@ module.exports = {
|
||||||
if (!claim) {
|
if (!claim) {
|
||||||
throw new Error('no record found in Claim table');
|
throw new Error('no record found in Claim table');
|
||||||
}
|
}
|
||||||
claim.dataValues.thumbnail = chooseThumbnail(claim.dataValues.thumbnail, DEFAULT_THUMBNAIL);
|
claim.dataValues.thumbnail = module.exports.chooseThumbnail(claim.dataValues.thumbnail, DEFAULT_THUMBNAIL);
|
||||||
|
claim.dataValues.fileExt = module.exports.determineFileExtensionFromContentType(claim.dataValues.contentType);
|
||||||
return claim.dataValues;
|
return claim.dataValues;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
determineFileExtensionFromContentType (contentType) {
|
||||||
|
switch (contentType) {
|
||||||
|
case 'image/jpeg':
|
||||||
|
return 'jpeg';
|
||||||
|
case 'image/jpg':
|
||||||
|
return 'jpg';
|
||||||
|
case 'image/png':
|
||||||
|
return 'png';
|
||||||
|
case 'image/gif':
|
||||||
|
return 'gif';
|
||||||
|
case 'video/mp4':
|
||||||
|
return 'mp4';
|
||||||
|
default:
|
||||||
|
logger.info('showing unknown file type as image/jpeg');
|
||||||
|
return 'jpeg';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
chooseThumbnail (claimInfo, defaultThumbnail) {
|
||||||
|
if (!claimInfo.thumbnail || claimInfo.thumbnail.trim() === '') {
|
||||||
|
return defaultThumbnail;
|
||||||
|
}
|
||||||
|
return claimInfo.thumbnail;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -259,11 +259,11 @@ module.exports = (app) => {
|
||||||
}
|
}
|
||||||
// show, showlite, or serve
|
// show, showlite, or serve
|
||||||
switch (responseType) {
|
switch (responseType) {
|
||||||
case SERVE:
|
case SHOW:
|
||||||
return showAssetToClient(claimId, name, res);
|
return showAssetToClient(claimId, name, res);
|
||||||
case SHOWLITE:
|
case SHOWLITE:
|
||||||
return showPlainAssetToClient(claimId, name, res);
|
return showPlainAssetToClient(claimId, name, res);
|
||||||
case SHOW:
|
case SERVE:
|
||||||
return serveAssetToClient(claimId, name, res);
|
return serveAssetToClient(claimId, name, res);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -303,11 +303,11 @@ module.exports = (app) => {
|
||||||
}
|
}
|
||||||
// show, showlite, or serve
|
// show, showlite, or serve
|
||||||
switch (responseType) {
|
switch (responseType) {
|
||||||
case SERVE:
|
case SHOW:
|
||||||
return showAssetToClient(claimId, name, res);
|
return showAssetToClient(claimId, name, res);
|
||||||
case SHOWLITE:
|
case SHOWLITE:
|
||||||
return showPlainAssetToClient(claimId, name, res);
|
return showPlainAssetToClient(claimId, name, res);
|
||||||
case SHOW:
|
case SERVE:
|
||||||
return serveAssetToClient(claimId, name, res);
|
return serveAssetToClient(claimId, name, res);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue