changed the multipart download directory
This commit is contained in:
parent
0517326c43
commit
63458aff19
4 changed files with 14 additions and 9 deletions
|
@ -6,13 +6,13 @@ const publishHelpers = require('../helpers/publishHelpers.js');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
publish (publishParams, fileName, fileType) {
|
publish (publishParams, fileName, fileType) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let publishResults = {};
|
let publishResults, certificateId, channelName;
|
||||||
// 1. publish the file
|
// publish the file
|
||||||
return lbryApi.publishClaim(publishParams)
|
return lbryApi.publishClaim(publishParams)
|
||||||
// 2. upsert File record (update is in case the claim has been published before by this daemon)
|
|
||||||
.then(tx => {
|
.then(tx => {
|
||||||
logger.info(`Successfully published ${fileName}`, tx);
|
logger.info(`Successfully published ${fileName}`, tx);
|
||||||
publishResults = tx;
|
publishResults = tx;
|
||||||
|
// get the channel information
|
||||||
if (publishParams.channel_name) {
|
if (publishParams.channel_name) {
|
||||||
logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);
|
logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);
|
||||||
return db.Channel.findOne({where: {channelName: publishParams.channel_name}});
|
return db.Channel.findOne({where: {channelName: publishParams.channel_name}});
|
||||||
|
@ -22,13 +22,16 @@ module.exports = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(channel => {
|
.then(channel => {
|
||||||
let certificateId = null;
|
certificateId = null;
|
||||||
let channelName = null;
|
channelName = null;
|
||||||
if (channel) {
|
if (channel) {
|
||||||
certificateId = channel.channelClaimId;
|
certificateId = channel.channelClaimId;
|
||||||
channelName = channel.channelName;
|
channelName = channel.channelName;
|
||||||
}
|
}
|
||||||
logger.debug(`certificateId: ${certificateId}`);
|
logger.debug(`certificateId: ${certificateId}`);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
// create the File record
|
||||||
const fileRecord = {
|
const fileRecord = {
|
||||||
name : publishParams.name,
|
name : publishParams.name,
|
||||||
claimId : publishResults.claim_id,
|
claimId : publishResults.claim_id,
|
||||||
|
@ -42,6 +45,7 @@ module.exports = {
|
||||||
fileType,
|
fileType,
|
||||||
nsfw : publishParams.metadata.nsfw,
|
nsfw : publishParams.metadata.nsfw,
|
||||||
};
|
};
|
||||||
|
// create the Claim record
|
||||||
const claimRecord = {
|
const claimRecord = {
|
||||||
name : publishParams.name,
|
name : publishParams.name,
|
||||||
claimId : publishResults.claim_id,
|
claimId : publishResults.claim_id,
|
||||||
|
@ -57,6 +61,7 @@ module.exports = {
|
||||||
certificateId,
|
certificateId,
|
||||||
channelName,
|
channelName,
|
||||||
};
|
};
|
||||||
|
// upsert File record (update is in case the claim has been published before by this daemon)
|
||||||
const upsertCriteria = {
|
const upsertCriteria = {
|
||||||
name : publishParams.name,
|
name : publishParams.name,
|
||||||
claimId: publishResults.claim_id,
|
claimId: publishResults.claim_id,
|
||||||
|
|
|
@ -66,7 +66,7 @@ db.upsert = (Model, values, condition, tableName) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
logger.error('Sequelize findOne error', error);
|
logger.error(`${tableName}.upsert error`, error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
"cookie-session": "^2.0.0-beta.3",
|
"cookie-session": "^2.0.0-beta.3",
|
||||||
"express": "^4.15.2",
|
"express": "^4.15.2",
|
||||||
"express-handlebars": "^3.0.0",
|
"express-handlebars": "^3.0.0",
|
||||||
"express-session": "^1.15.5",
|
|
||||||
"form-data": "^2.3.1",
|
"form-data": "^2.3.1",
|
||||||
"helmet": "^3.8.1",
|
"helmet": "^3.8.1",
|
||||||
"mysql2": "^1.3.5",
|
"mysql2": "^1.3.5",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const multipart = require('connect-multiparty');
|
const multipart = require('connect-multiparty');
|
||||||
const multipartMiddleware = multipart();
|
const multipartMiddleware = multipart({uploadDir: '/home/lbry/test/'});
|
||||||
const db = require('../models');
|
const db = require('../models');
|
||||||
const { publish } = require('../controllers/publishController.js');
|
const { publish } = require('../controllers/publishController.js');
|
||||||
const { getClaimList, resolveUri } = require('../helpers/lbryApi.js');
|
const { getClaimList, resolveUri } = require('../helpers/lbryApi.js');
|
||||||
|
@ -73,6 +73,7 @@ module.exports = (app) => {
|
||||||
// route to run a publish request on the daemon
|
// route to run a publish request on the daemon
|
||||||
app.post('/api/publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => {
|
app.post('/api/publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => {
|
||||||
logger.debug('api/publish body:', body);
|
logger.debug('api/publish body:', body);
|
||||||
|
logger.debug('api/publish body:', files);
|
||||||
let file, fileName, filePath, fileType, name, nsfw, license, title, description, thumbnail, anonymous, skipAuth, channelName, channelPassword;
|
let file, fileName, filePath, fileType, name, nsfw, license, title, description, thumbnail, anonymous, skipAuth, channelName, channelPassword;
|
||||||
// validate that mandatory parts of the request are present
|
// validate that mandatory parts of the request are present
|
||||||
try {
|
try {
|
||||||
|
@ -84,7 +85,7 @@ module.exports = (app) => {
|
||||||
}
|
}
|
||||||
// validate file, name, license, and nsfw
|
// validate file, name, license, and nsfw
|
||||||
file = files.file;
|
file = files.file;
|
||||||
fileName = file.name;
|
fileName = file.path.substring(file.path.lastIndexOf('/') + 1);
|
||||||
filePath = file.path;
|
filePath = file.path;
|
||||||
fileType = file.type;
|
fileType = file.type;
|
||||||
name = body.name;
|
name = body.name;
|
||||||
|
|
Loading…
Reference in a new issue