Skip to content

Commit

Permalink
Merge pull request #10 from mbrevoort/feature/delete-file
Browse files Browse the repository at this point in the history
Added ability to delete file from S3 with deleteFile function
  • Loading branch information
roycehaynes committed Mar 11, 2014
2 parents 76e1a43 + 62a2670 commit cf372e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,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;

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.'}));
}
});
}; // 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() }));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit cf372e9

Please sign in to comment.