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": {
|
||||
"lbryAddress": "LBRY_WALLET_ADDRESS"
|
||||
"LbryAddress": "LBRY_WALLET_ADDRESS"
|
||||
},
|
||||
"Database": {
|
||||
"MySqlConnectionUri": "MYSQL_CONNECTION_STRING"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"WalletConfig": {
|
||||
"lbryAddress": "none"
|
||||
"LbryAddress": "none"
|
||||
},
|
||||
"AnalyticsConfig":{
|
||||
"googleId": "none"
|
||||
"GoogleId": "none"
|
||||
},
|
||||
"Database": {
|
||||
"MySqlConnectionUri": "none",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"WalletConfig": {
|
||||
"lbryAddress": "none"
|
||||
"LbryAddress": "none"
|
||||
},
|
||||
"AnalyticsConfig":{
|
||||
"googleId": "UA-100747990-1"
|
||||
"GoogleId": "UA-100747990-1"
|
||||
},
|
||||
"Database": {
|
||||
"MySqlConnectionUri": "none",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"WalletConfig": {
|
||||
"lbryAddress": "none"
|
||||
"LbryAddress": "none"
|
||||
},
|
||||
"AnalyticsConfig":{
|
||||
"googleId": "UA-100747990-1"
|
||||
"GoogleId": "UA-100747990-1"
|
||||
},
|
||||
"Database": {
|
||||
"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 multipart = require('connect-multiparty');
|
||||
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 errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
||||
|
||||
module.exports = app => {
|
||||
// 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) => {
|
||||
logger.debug(`POST request on ${originalUrl}`);
|
||||
console.log('>> req.files:', files);
|
||||
console.log(' >> req.body:', body);
|
||||
const name = body.claimName;
|
||||
const license = body.license;
|
||||
const nsfw = body.nsfw;
|
||||
const fileName = files.file1.name;
|
||||
const filePath = files.file1.path;
|
||||
const fileType = files.file1.type;
|
||||
console.log('>> req.body:', body);
|
||||
const file = files.file1;
|
||||
if (!file) {
|
||||
res.status(500).json({ 'error': 'No file was submitted. Form submission must have key "speechFile"' });
|
||||
return;
|
||||
}
|
||||
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
|
||||
*/
|
||||
// prepare the publish parameters
|
||||
const publishParams = publishHelpers.createPublishParams(name, filePath, license, nsfw);
|
||||
console.log('publish params', publishParams);
|
||||
// publish the file
|
||||
publishController
|
||||
.publish(publishParams, fileName, fileType)
|
||||
|
@ -57,10 +63,10 @@ module.exports = app => {
|
|||
errorHandlers.handleRequestError(error, res);
|
||||
});
|
||||
|
||||
if (files) {
|
||||
res.status(200).json({'status': 'file(s) received'});
|
||||
} else {
|
||||
res.status(400).josn({'status': 'no files(s) received'});
|
||||
}
|
||||
// if (files) {
|
||||
// res.status(200).json({'status': 'file(s) received'});
|
||||
// } else {
|
||||
// res.status(400).josn({'status': 'no files(s) received'});
|
||||
// }
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const logger = require('winston');
|
||||
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');
|
||||
|
||||
module.exports = (app, siofu, hostedContentPath, ua, googleAnalyticsId) => {
|
||||
|
|
|
@ -8,13 +8,13 @@ const config = require('config');
|
|||
const ua = require('universal-analytics');
|
||||
const winston = require('winston');
|
||||
|
||||
const googleAnalyticsId = config.get('AnalyticsConfig.googleId');
|
||||
const googleAnalyticsId = config.get('AnalyticsConfig.GoogleId');
|
||||
const hostedContentPath = config.get('Database.PublishUploadPath');
|
||||
|
||||
// configure logging
|
||||
const logLevel = config.get('Logging.LogLevel');
|
||||
const logDir = config.get('Logging.LogDirectory');
|
||||
require('./helpers/logging/loggerSetup.js')(winston, logLevel, logDir);
|
||||
require('./config/loggerSetup.js')(winston, logLevel, logDir);
|
||||
|
||||
// set port
|
||||
const PORT = 3000;
|
||||
|
@ -38,7 +38,7 @@ const hbs = expressHandlebars.create({
|
|||
helpers : {
|
||||
// define any extra helpers you may need
|
||||
googleAnalytics () {
|
||||
const googleApiKey = config.get('AnalyticsConfig.googleId');
|
||||
const googleApiKey = config.get('AnalyticsConfig.GoogleId');
|
||||
return new Handlebars.SafeString(
|
||||
`<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
|
|
Loading…
Reference in a new issue