1. Alvaro Videla
  2. cloudstagram

Commits

Alvaro Videla  committed b529cdc

simplifies file serve logic

  • Participants
  • Parent commits b6c53f5
  • Branches master

Comments (0)

Files changed (1)

File routes/fileServe.js

View file
  • Ignore whitespace
 , image_storage = require('../lib/image_storage')
 ;
 
-function sendFile(res, data, mime, code) {
-    res.send(data, 
-             { 
-                 'Content-Type': mime,
-                 'Cache-Control': 'public, max-age=2592000'
-             }, code);
-}
-
 exports.serveFile = function(req, res, next) {
     var filename = req.params.id;
     image_storage.readGsFile(filename, function(error, gsData) {
             res.send(404);
         } else {
             console.log("serve file: ", gsData.gsObject.contentType);
-            sendFile(res, gsData.binary, gsData.gsObject.contentType, HTTPStatus.OK);   
+            res.send(gsData.binary, { 
+                'Content-Type': gsData.gsObject.contentType,
+                'Cache-Control': 'public, max-age=2592000'
+            }, HTTPStatus.OK);
         }
     });
 };