{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/multer/issues/126","labels_url":"https://api.github.com/repos/expressjs/multer/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/multer/issues/126/comments","events_url":"https://api.github.com/repos/expressjs/multer/issues/126/events","html_url":"https://github.com/expressjs/multer/pull/126","id":72407284,"number":126,"title":"[WIP] Storage API","user":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-01T11:03:46Z","updated_at":"2015-05-02T16:22:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/expressjs/multer/pulls/126","html_url":"https://github.com/expressjs/multer/pull/126","diff_url":"https://github.com/expressjs/multer/pull/126.diff","patch_url":"https://github.com/expressjs/multer/pull/126.patch"},"body":"*Don't pull yet*\r\n\r\nI took a stab at implementing what my thoughts where on the Storage API without actually breaking backwards compatibility.\r\n\r\n@dustin-H Would you be open to try and implement `pkgcloud` on top of this? Or I could do it for you and maybe you could help me try it out :)\r\n\r\nSo this is the basic specification for a plugin:\r\n\r\n```javascript\r\n// The implementation could be a class or just a plain object\r\n// This example uses a class\r\nfunction PkgcloudStorage (opts) {\r\n  this.client = opts.client\r\n  this.getDestination = opts.destination\r\n}\r\n\r\n// The class or object needs to expose one function: handleFile(req, file, cb)\r\nPkgcloudStorage.prototype.handleFile = function handleFile (req, file, cb) {\r\n  var that = this\r\n\r\n  that.getDestination(req, file, function (err, dest) {\r\n    if (err) return cb(err)\r\n\r\n    var params = {\r\n      container: dest.container,\r\n      remote: dest.remote,\r\n      contentType: file.mimetype\r\n    }\r\n    var outStream = that.client.upload(params)\r\n\r\n    file.stream.pipe(outStream)\r\n    outStream.on('error', cb)\r\n    outStream.on('success', function (info) {\r\n      cb(null, {\r\n        size: info.size,\r\n        container: dest.container,\r\n        remote: dest.remote\r\n      })\r\n    })\r\n  })\r\n}\r\n\r\n// The module should expose one function that returns the storage instance.\r\n// It should take one parameter: opts\r\nmodule.exports = function (opts) {\r\n  return new PkgcloudStorage(opts)\r\n}\r\n```\r\n\r\nIt would be used something like this:\r\n\r\n```javascript\r\nvar mutler = require('mutler')\r\nvar pkgcloudStorage = require('mutler-storage-pkgcloud')\r\n\r\nfunction destination (req, file, cb) { cb(null, { container: 'a', remote: 'b.txt' }) }\r\nvar storage = pkgcloudStorage({ client: _, destination: destination })\r\n\r\nmutler({ storage: storage })\r\n```"},"comment":{"url":"https://api.github.com/repos/expressjs/multer/issues/comments/98374893","html_url":"https://github.com/expressjs/multer/pull/126#issuecomment-98374893","issue_url":"https://api.github.com/repos/expressjs/multer/issues/126","id":98374893,"user":{"login":"jpfluger","id":6799005,"avatar_url":"https://avatars.githubusercontent.com/u/6799005?v=3","gravatar_id":"","url":"https://api.github.com/users/jpfluger","html_url":"https://github.com/jpfluger","followers_url":"https://api.github.com/users/jpfluger/followers","following_url":"https://api.github.com/users/jpfluger/following{/other_user}","gists_url":"https://api.github.com/users/jpfluger/gists{/gist_id}","starred_url":"https://api.github.com/users/jpfluger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpfluger/subscriptions","organizations_url":"https://api.github.com/users/jpfluger/orgs","repos_url":"https://api.github.com/users/jpfluger/repos","events_url":"https://api.github.com/users/jpfluger/events{/privacy}","received_events_url":"https://api.github.com/users/jpfluger/received_events","type":"User","site_admin":false},"created_at":"2015-05-02T16:22:40Z","updated_at":"2015-05-02T16:22:40Z","body":":+1: "}}