From 540159e1ddc869753386a54dad30fed6d2bbce84 Mon Sep 17 00:00:00 2001 From: "Haynes, Royce L" Date: Thu, 6 Mar 2014 08:35:33 -0700 Subject: [PATCH 1/3] Added ability to delete file from S3 with deleteFile function --- index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/index.js b/index.js index 3fc9db8..80721af 100644 --- a/index.js +++ b/index.js @@ -213,6 +213,28 @@ var Framer = module.exports = function Framer(opts) { }; }; + + this.deleteFile = function(opts){ + if (!opts) opts = {}; + opts.prefix = opts.prefix || ""; + + return function(req, res, cb) { + cb = cb === undefined ? null : cb; + + uri = require('url').parse(req.url, true).pathname; + res.setHeader('Content-Type', s3res.headers['content-type']); + + self._s3Client.deleteFile(uri, function(err, res){ + if(cb){ + cb(err, res); + } else { + res.end(JSON.stringify({statusCode: 200, message: 'File deleted.'})); + } + }); + }; // end of return function object + + }; // end of deleteFile + this._handleError = function (code, res, err) { res.writeHead(code, {'content-type': 'application/json'}); res.end(JSON.stringify({ statusCode: code, error: err.toString() })); From d06d7d0b25b6dd723e0b5649a667a20a343958e1 Mon Sep 17 00:00:00 2001 From: "Haynes, Royce L" Date: Thu, 6 Mar 2014 08:49:50 -0700 Subject: [PATCH 2/3] Uptick version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e41ec4..211dc0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "framer", - "version": "0.3.4", + "version": "0.4.0", "description": "A simple dynamic photo resizing http server intended to be behind an http cache that stores files in S3", "main": "index.js", "scripts": { From 62a2670b8146567b22e9dc2fa23c35ed0d1a71d5 Mon Sep 17 00:00:00 2001 From: "Haynes, Royce L" Date: Thu, 6 Mar 2014 09:01:11 -0700 Subject: [PATCH 3/3] Set header of response if callback isn't being used. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 80721af..e59d1fe 100644 --- a/index.js +++ b/index.js @@ -222,12 +222,12 @@ var Framer = module.exports = function Framer(opts) { cb = cb === undefined ? null : cb; uri = require('url').parse(req.url, true).pathname; - res.setHeader('Content-Type', s3res.headers['content-type']); self._s3Client.deleteFile(uri, function(err, res){ if(cb){ cb(err, res); } else { + res.setHeader('Content-Type', s3res.headers['content-type']); res.end(JSON.stringify({statusCode: 200, message: 'File deleted.'})); } });