route is properly pulling metadata
This commit is contained in:
parent
1188d73f5d
commit
5c95b5c7ec
8 changed files with 32 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"WalletConfig": {
|
"WalletConfig": {
|
||||||
"lbryAddress": "LBRY_WALLET_ADDRESS"
|
"LbryAddress": "LBRY_WALLET_ADDRESS"
|
||||||
},
|
},
|
||||||
"Database": {
|
"Database": {
|
||||||
"MySqlConnectionUri": "MYSQL_CONNECTION_STRING"
|
"MySqlConnectionUri": "MYSQL_CONNECTION_STRING"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"WalletConfig": {
|
"WalletConfig": {
|
||||||
"lbryAddress": "none"
|
"LbryAddress": "none"
|
||||||
},
|
},
|
||||||
"AnalyticsConfig":{
|
"AnalyticsConfig":{
|
||||||
"googleId": "none"
|
"GoogleId": "none"
|
||||||
},
|
},
|
||||||
"Database": {
|
"Database": {
|
||||||
"MySqlConnectionUri": "none",
|
"MySqlConnectionUri": "none",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"WalletConfig": {
|
"WalletConfig": {
|
||||||
"lbryAddress": "none"
|
"LbryAddress": "none"
|
||||||
},
|
},
|
||||||
"AnalyticsConfig":{
|
"AnalyticsConfig":{
|
||||||
"googleId": "UA-100747990-1"
|
"GoogleId": "UA-100747990-1"
|
||||||
},
|
},
|
||||||
"Database": {
|
"Database": {
|
||||||
"MySqlConnectionUri": "none",
|
"MySqlConnectionUri": "none",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"WalletConfig": {
|
"WalletConfig": {
|
||||||
"lbryAddress": "none"
|
"LbryAddress": "none"
|
||||||
},
|
},
|
||||||
"AnalyticsConfig":{
|
"AnalyticsConfig":{
|
||||||
"googleId": "UA-100747990-1"
|
"GoogleId": "UA-100747990-1"
|
||||||
},
|
},
|
||||||
"Database": {
|
"Database": {
|
||||||
"MySqlConnectionUri": "none",
|
"MySqlConnectionUri": "none",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
|
||||||
const lbryApi = require('../helpers/libraries/lbryApi.js');
|
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const multipart = require('connect-multiparty');
|
const multipart = require('connect-multiparty');
|
||||||
const multipartMiddleware = multipart();
|
const multipartMiddleware = multipart();
|
||||||
const publishController = require('../helpers/libraries/publishController.js');
|
const publishController = require('../controllers/publishController.js');
|
||||||
|
const lbryApi = require('../helpers/libraries/lbryApi.js');
|
||||||
const publishHelpers = require('../helpers/libraries/publishHelpers.js');
|
const publishHelpers = require('../helpers/libraries/publishHelpers.js');
|
||||||
|
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
||||||
|
|
||||||
module.exports = app => {
|
module.exports = app => {
|
||||||
// route to run a claim_list request on the daemon
|
// route to run a claim_list request on the daemon
|
||||||
|
@ -35,18 +35,24 @@ module.exports = app => {
|
||||||
app.post('/api/publish', multipartMiddleware, ({ originalUrl, body, files }, res) => {
|
app.post('/api/publish', multipartMiddleware, ({ originalUrl, body, files }, res) => {
|
||||||
logger.debug(`POST request on ${originalUrl}`);
|
logger.debug(`POST request on ${originalUrl}`);
|
||||||
console.log('>> req.files:', files);
|
console.log('>> req.files:', files);
|
||||||
console.log(' >> req.body:', body);
|
console.log('>> req.body:', body);
|
||||||
const name = body.claimName;
|
const file = files.file1;
|
||||||
const license = body.license;
|
if (!file) {
|
||||||
const nsfw = body.nsfw;
|
res.status(500).json({ 'error': 'No file was submitted. Form submission must have key "speechFile"' });
|
||||||
const fileName = files.file1.name;
|
return;
|
||||||
const filePath = files.file1.path;
|
}
|
||||||
const fileType = files.file1.type;
|
const name = body.claim || file.name.substring(0, file.name.indexOf('.'));
|
||||||
|
const license = body.license || 'No License Provided';
|
||||||
|
const nsfw = body.nsfw || true;
|
||||||
|
const fileName = file.name;
|
||||||
|
const filePath = file.path;
|
||||||
|
const fileType = file.type;
|
||||||
/*
|
/*
|
||||||
make sure it's not a harmful file type
|
make sure it's not a harmful file type
|
||||||
*/
|
*/
|
||||||
// prepare the publish parameters
|
// prepare the publish parameters
|
||||||
const publishParams = publishHelpers.createPublishParams(name, filePath, license, nsfw);
|
const publishParams = publishHelpers.createPublishParams(name, filePath, license, nsfw);
|
||||||
|
console.log('publish params', publishParams);
|
||||||
// publish the file
|
// publish the file
|
||||||
publishController
|
publishController
|
||||||
.publish(publishParams, fileName, fileType)
|
.publish(publishParams, fileName, fileType)
|
||||||
|
@ -57,10 +63,10 @@ module.exports = app => {
|
||||||
errorHandlers.handleRequestError(error, res);
|
errorHandlers.handleRequestError(error, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (files) {
|
// if (files) {
|
||||||
res.status(200).json({'status': 'file(s) received'});
|
// res.status(200).json({'status': 'file(s) received'});
|
||||||
} else {
|
// } else {
|
||||||
res.status(400).josn({'status': 'no files(s) received'});
|
// res.status(400).josn({'status': 'no files(s) received'});
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const publishController = require('../controllers/publishController.js');
|
const publishController = require('../controllers/publishController.js');
|
||||||
const publishHelpers = require('../controllers/publishHelpers.js');
|
const publishHelpers = require('../helpers/libraries/publishHelpers.js');
|
||||||
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
||||||
|
|
||||||
module.exports = (app, siofu, hostedContentPath, ua, googleAnalyticsId) => {
|
module.exports = (app, siofu, hostedContentPath, ua, googleAnalyticsId) => {
|
||||||
|
|
|
@ -8,13 +8,13 @@ const config = require('config');
|
||||||
const ua = require('universal-analytics');
|
const ua = require('universal-analytics');
|
||||||
const winston = require('winston');
|
const winston = require('winston');
|
||||||
|
|
||||||
const googleAnalyticsId = config.get('AnalyticsConfig.googleId');
|
const googleAnalyticsId = config.get('AnalyticsConfig.GoogleId');
|
||||||
const hostedContentPath = config.get('Database.PublishUploadPath');
|
const hostedContentPath = config.get('Database.PublishUploadPath');
|
||||||
|
|
||||||
// configure logging
|
// configure logging
|
||||||
const logLevel = config.get('Logging.LogLevel');
|
const logLevel = config.get('Logging.LogLevel');
|
||||||
const logDir = config.get('Logging.LogDirectory');
|
const logDir = config.get('Logging.LogDirectory');
|
||||||
require('./helpers/logging/loggerSetup.js')(winston, logLevel, logDir);
|
require('./config/loggerSetup.js')(winston, logLevel, logDir);
|
||||||
|
|
||||||
// set port
|
// set port
|
||||||
const PORT = 3000;
|
const PORT = 3000;
|
||||||
|
@ -38,7 +38,7 @@ const hbs = expressHandlebars.create({
|
||||||
helpers : {
|
helpers : {
|
||||||
// define any extra helpers you may need
|
// define any extra helpers you may need
|
||||||
googleAnalytics () {
|
googleAnalytics () {
|
||||||
const googleApiKey = config.get('AnalyticsConfig.googleId');
|
const googleApiKey = config.get('AnalyticsConfig.GoogleId');
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`<script>
|
`<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
|
Loading…
Reference in a new issue