fix checking file early

This commit is contained in:
Emily Hou 2018-06-21 16:36:34 -07:00
parent e4a0028f5d
commit 12ccce3016
4 changed files with 6 additions and 11 deletions

View file

@ -62,10 +62,6 @@ module.exports = function(app) {
app.post(`/api/params/:id${ID_REGEX}`, owner, require('./params'));
app.post(`/api/info/:id${ID_REGEX}`, owner, require('./info'));
if (!IS_DEV) {
app.ws('/api/ws', require('./ws'));
}
app.get('/__version__', function(req, res) {
res.sendFile(require.resolve('../../dist/version.json'));
});

View file

@ -44,13 +44,13 @@ module.exports = async function(ws, req) {
nonce: crypto.randomBytes(16).toString('base64')
};
const protocol = config.env === 'production' ? 'https' : req.protocol;
const url = `${protocol}://${req.get('host')}/download/${newId}/`;
const limiter = new Limiter(config.max_file_size);
fileStream = wsStream(ws, { binary: true }).pipe(limiter);
storage.set(newId, fileStream, meta);
const protocol = config.env === 'production' ? 'https' : req.protocol;
const url = `${protocol}://${req.get('host')}/download/${newId}/`;
ws.send(
JSON.stringify({
url,