switched api/streamFile to static /media
This commit is contained in:
parent
032066260b
commit
0de27c0b1b
6 changed files with 20 additions and 22 deletions
|
@ -8,11 +8,6 @@ const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
|||
const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||
|
||||
module.exports = (app, hostedContentPath) => {
|
||||
// route to return a file directly
|
||||
app.get('/api/streamFile/:name', ({ params }, 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
|
||||
|
|
23
speech.js
23
speech.js
|
@ -16,15 +16,15 @@ const db = require('./models'); // require our models for syncing
|
|||
const logLevel = config.get('Logging.LogLevel');
|
||||
require('./config/loggerSetup.js')(logger, logLevel);
|
||||
|
||||
// serve static files from public directory (css/js/img)
|
||||
app.use(express.static(`${__dirname}/public`));
|
||||
|
||||
// configure express app
|
||||
app.enable('trust proxy'); // trust the proxy to get ip address for us
|
||||
app.use(bodyParser.json()); // for parsing application/json
|
||||
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
||||
app.use(siofu.router);
|
||||
app.use((req, res, next) => { // logging middleware
|
||||
// trust the proxy to get ip address for us
|
||||
app.enable('trust proxy');
|
||||
// add middleware
|
||||
app.use(express.static(`${__dirname}/public`)); // 'express.static' to serve static files from public directory
|
||||
app.use(express.static(`${__dirname}/public`)); // 'express.static' to serve static files from public directory
|
||||
app.use(bodyParser.json()); // 'body parser' for parsing application/json
|
||||
app.use(bodyParser.urlencoded({ extended: true })); // 'body parser' for parsing application/x-www-form-urlencoded
|
||||
app.use(siofu.router); // 'socketio-file-upload' router for uploading with socket.io
|
||||
app.use((req, res, next) => { // custom logging middleware to log all incomming http requests
|
||||
logger.verbose(`Request on ${req.originalUrl} from ${req.ip}`);
|
||||
next();
|
||||
});
|
||||
|
@ -84,7 +84,10 @@ db.sequelize
|
|||
logger.info('Retrieving daemon download directory');
|
||||
return getDownloadDirectory();
|
||||
})
|
||||
.then(hostedContentPath => { // require routes & wrap in socket.io
|
||||
.then(hostedContentPath => {
|
||||
// add the hosted content folder at a static path
|
||||
app.use('/media', express.static(hostedContentPath));
|
||||
// require routes & wrap in socket.io
|
||||
require('./routes/api-routes.js')(app, hostedContentPath);
|
||||
require('./routes/show-routes.js')(app);
|
||||
require('./routes/serve-routes.js')(app);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<meta name="twitter:creator" content="@spee.ch">
|
||||
<meta name="twitter:title" content="{{fileInfo.name}}">
|
||||
<meta name="twitter:description" content="An image hosted via Spee.ch">
|
||||
<meta name="twitter:image" content="https://spee.ch/api/streamFile/{{fileInfo.fileName}}">
|
||||
<meta name="twitter:image" content="https://spee.ch/media/{{fileInfo.fileName}}">
|
||||
</head>
|
||||
<body>
|
||||
{{{ body }}}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<div id="asset-placeholder">
|
||||
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
|
||||
<video class="show-asset" autoplay loop controls>
|
||||
<source src="/api/streamFile/{{fileInfo.fileName}}">
|
||||
<source src="/media/{{fileInfo.fileName}}">
|
||||
{{!--fallback--}}
|
||||
Your browser does not support the <code>video</code> element.
|
||||
</video>
|
||||
{{else}}
|
||||
<img class="show-asset" src="/api/streamFile/{{fileInfo.fileName}}" />
|
||||
<img class="show-asset" src="/media/{{fileInfo.fileName}}" />
|
||||
{{/ifConditional}}
|
||||
</div>
|
||||
</div>
|
|
@ -8,12 +8,12 @@
|
|||
<a href="/{{this.name}}/{{this.claimId}}">
|
||||
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
||||
<video class="grid-item trending-video" controls>
|
||||
<source src="/api/streamFile/{{this.fileName}}">
|
||||
<source src="/media/{{this.fileName}}">
|
||||
{{!--fallback--}}
|
||||
Your browser does not support the <code>video</code> element.
|
||||
</video>
|
||||
{{else}}
|
||||
<img class="grid-item trending-image" src="/api/streamFile/{{this.fileName}}" />
|
||||
<img class="grid-item trending-image" src="/media/{{this.fileName}}" />
|
||||
{{/ifConditional}}
|
||||
</a>
|
||||
{{/unless}}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
<a href="/{{fileInfo.name}}/{{fileInfo.claimId}}">
|
||||
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
|
||||
<video class="show-asset-lite" autoplay loop controls>
|
||||
<source src="/api/streamFile/{{fileInfo.fileName}}">
|
||||
<source src="/media/{{fileInfo.fileName}}">
|
||||
{{!--fallback--}}
|
||||
Your browser does not support the <code>video</code> element.
|
||||
</video>
|
||||
|
||||
{{else}}
|
||||
<img class="show-asset-lite" src="/api/streamFile/{{fileInfo.fileName}}" alt="{{fileInfo.fileName}}"/>
|
||||
<img class="show-asset-lite" src="/media/{{fileInfo.fileName}}" alt="{{fileInfo.fileName}}"/>
|
||||
{{/ifConditional}}
|
||||
</a>
|
||||
</div>
|
Loading…
Reference in a new issue