serve static assets on urls with file extension #538
2 changed files with 8 additions and 4 deletions
|
@ -27,6 +27,7 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
ip,
|
ip,
|
||||||
headers,
|
headers,
|
||||||
body,
|
body,
|
||||||
|
files,
|
||||||
});
|
});
|
||||||
// check for disabled publishing
|
// check for disabled publishing
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
|
@ -36,14 +37,14 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// define variables
|
// define variables
|
||||||
let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title;
|
let channelName, channelId, channelPassword, description, fileName, filePath, fileExtension, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title;
|
||||||
// record the start time of the request
|
// record the start time of the request
|
||||||
gaStartTime = Date.now();
|
gaStartTime = Date.now();
|
||||||
// validate the body and files of the request
|
// validate the body and files of the request
|
||||||
try {
|
try {
|
||||||
// validateApiPublishRequest(body, files);
|
// validateApiPublishRequest(body, files);
|
||||||
({name, nsfw, license, title, description, thumbnail} = parsePublishApiRequestBody(body));
|
({name, nsfw, license, title, description, thumbnail} = parsePublishApiRequestBody(body));
|
||||||
({fileName, filePath, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files));
|
({fileName, filePath, fileExtension, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files));
|
||||||
({channelName, channelId, channelPassword} = body);
|
({channelName, channelId, channelPassword} = body);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return res.status(400).json({success: false, message: error.message});
|
return res.status(400).json({success: false, message: error.message});
|
||||||
|
@ -76,8 +77,9 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
data : {
|
data : {
|
||||||
name,
|
name,
|
||||||
claimId : result.claim_id,
|
claimId : result.claim_id,
|
||||||
url : `${host}/${result.claim_id}/${name}`,
|
url : `${host}/${result.claim_id}/${name}`, // for backwards compatability with app
|
||||||
embedUrl: `${host}/asset/${name}/${result.claim_id}`,
|
showUrl : `${host}/${result.claim_id}/${name}`,
|
||||||
|
serveUrl: `${host}/${result.claim_id}/${name}${fileExtension}`,
|
||||||
lbryTx : result,
|
lbryTx : result,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const path = require('path');
|
||||||
const validateFileTypeAndSize = require('./validateFileTypeAndSize.js');
|
const validateFileTypeAndSize = require('./validateFileTypeAndSize.js');
|
||||||
|
|
||||||
const parsePublishApiRequestFiles = ({file, thumbnail}) => {
|
const parsePublishApiRequestFiles = ({file, thumbnail}) => {
|
||||||
|
@ -33,6 +34,7 @@ const parsePublishApiRequestFiles = ({file, thumbnail}) => {
|
||||||
return {
|
return {
|
||||||
fileName : file.name,
|
fileName : file.name,
|
||||||
filePath : file.path,
|
filePath : file.path,
|
||||||
|
fileExtension : path.extname(file.path),
|
||||||
fileType : file.type,
|
fileType : file.type,
|
||||||
thumbnailFileName: (thumbnail ? thumbnail.name : null),
|
thumbnailFileName: (thumbnail ? thumbnail.name : null),
|
||||||
thumbnailFilePath: (thumbnail ? thumbnail.path : null),
|
thumbnailFilePath: (thumbnail ? thumbnail.path : null),
|
||||||
|
|
Loading…
Reference in a new issue