diff --git a/app/file-upload/server/config/Webdav.js b/app/file-upload/server/config/Webdav.js index 85def43bdf7e..8c5382b6b77e 100644 --- a/app/file-upload/server/config/Webdav.js +++ b/app/file-upload/server/config/Webdav.js @@ -5,7 +5,16 @@ import { settings } from '../../../settings'; import '../../ufs/Webdav/server.js'; const get = function(file, req, res) { - this.store.getReadStream(file._id, file).pipe(res); + this.store.getReadStream(file._id, file) + .on('error', () => { + console.error('An error ocurred when fetching the file'); + res.writeHead(503); + res.end(); + }) + .on('data', (chunk) => { + res.write(chunk); + }) + .on('end', res.end.bind(res)); }; const copy = function(file, out) {