Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- metaEngine.getAsync( id ).then( function( meta ){
- console.log( 'success!' )
- res.set( 'Content-Type', meta.mimeType )
- res.set( 'Content-Length', file.length )
- return storageEngine.getAsync( id )
- }, function(){
- console.log( 'failure!' )
- res.status( 404 )
- } ).then( function( file ){
- console.log( 'still running' )
- if( file.pipe ){
- file.pipe( res )
- return
- } else if( typeof file === 'string' || Buffer.isBuffer( file ) ){
- res.send( file )
- } else {
- res.status( 500 )
- throw new Error( 'Invalid file returned. Please return ReadableStream, string, or Buffer' )
- }
- }, function(){
- res.status( 500 )
- } )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement