diff --git a/config/development.json b/config/development.json index 691528f2..9b0e04cf 100644 --- a/config/development.json +++ b/config/development.json @@ -9,7 +9,7 @@ }, "Database": { "MySqlConnectionUri": "none", - "PublishUploadPath": "C:\\lbry\\speech\\hosted_content" + "PublishUploadPath": "C:\\lbry\\speech\\hosted_content\\" }, "Logging": { "LogLevel": "silly", diff --git a/routes/api-routes.js b/routes/api-routes.js index f3e06263..67c82d95 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -7,7 +7,15 @@ const { createPublishParams, validateFile } = require('../helpers/libraries/publ const errorHandlers = require('../helpers/libraries/errorHandlers.js'); const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js'); +const config = require('config'); +const hostedContentPath = config.get('Database.PublishUploadPath'); + module.exports = app => { + // route to run a claim_list request on the daemon + app.get('/api/streamFile/:name', ({ params, headers }, res) => { + const filePath = `${hostedContentPath}${params.name}`; + res.status(200).sendFile(filePath); + }); // route to run a claim_list request on the daemon app.get('/api/claim_list/:name', ({ headers, ip, originalUrl, params }, res) => { // google analytics diff --git a/routes/sockets-routes.js b/routes/sockets-routes.js index 7f3179e4..a828737c 100644 --- a/routes/sockets-routes.js +++ b/routes/sockets-routes.js @@ -1,5 +1,4 @@ const logger = require('winston'); -const fs = require('fs'); const publishController = require('../controllers/publishController.js'); const publishHelpers = require('../helpers/libraries/publishHelpers.js'); const errorHandlers = require('../helpers/libraries/errorHandlers.js'); @@ -57,42 +56,6 @@ module.exports = (app, siofu, hostedContentPath) => { // to-do: remove the file if not done automatically } }); - // handle asset requests - socket.on('asset-request', filePath => { - logger.debug('received a request for the following file', filePath); - fs.readFile(filePath, (err, assetBuffer) => { - if (err) { - logger.error('fs.readFile error', err); - return; - }; - // set the data - const fileExtension = filePath.substring(filePath.lastIndexOf('.')); - let data = { - type : null, - buffer: assetBuffer.toString('base64'), - }; - switch (fileExtension) { - case '.jpeg' || '.jpg': - data['type'] = 'image/jpeg'; - break; - case '.gif': - data['type'] = 'image/gif'; - break; - case '.png': - data['type'] = 'image/png'; - break; - case '.mp4': - data['type'] = 'video/mp4'; - break; - default: - data['type'] = 'image/jpeg'; - logger.warn('showing file with unknown type as jpeg'); - break; - } - // send the asset - socket.emit('asset-transfer', data); - }); - }); // handle disconnect socket.on('disconnect', () => { logger.silly('a user disconnected via sockets'); diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 96cdf84f..44c5a873 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -1,35 +1,13 @@
-
-

loading...

+
+ {{#ifConditional fileInfo.fileType '===' 'video/mp4'}} + + {{else}} + + {{/ifConditional}}
-
- - - \ No newline at end of file +
\ No newline at end of file diff --git a/views/partials/assetInfo.handlebars b/views/partials/assetInfo.handlebars index ac51be25..6aa678a4 100644 --- a/views/partials/assetInfo.handlebars +++ b/views/partials/assetInfo.handlebars @@ -13,7 +13,7 @@ Embed HTML
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}} - + {{else}} {{/ifConditional}} diff --git a/views/showLite.handlebars b/views/showLite.handlebars index f57a67ce..e2550ed1 100644 --- a/views/showLite.handlebars +++ b/views/showLite.handlebars @@ -1,33 +1,11 @@ -
-

loading...

-
- - - \ No newline at end of file +
+ {{#ifConditional fileInfo.fileType '===' 'video/mp4'}} + + {{else}} + + {{/ifConditional}} +
\ No newline at end of file