Commit 8feaa986 authored by James Calfee's avatar James Calfee
Browse files

Removed unused type parameter

parent 8c8aa654
......@@ -13,11 +13,11 @@ See also: `./config/index.js`
#### Download the test image
> curl -v http://localhost:3234/image/a190c0596a37398427e51bcbee7c94f1007075629828d62005735c6c2d2ffeef > $HOME/Pictures/blue_red_pill.jpg
> curl -v http://localhost:3234/a190c0596a37398427e51bcbee7c94f1007075629828d62005735c6c2d2ffeef > $HOME/Pictures/blue_red_pill.jpg
#### Upload again (user `steem` signed using a test key)
> curl -v -F "data=@$HOME/Pictures/blue_red_pill.jpg" http://localhost:3234/image/steem/205d8bcafb9e0e0897e2db330aa2bd1ca4f7764ad9b1ba04a2a9651453aee72f4a685bd631ad60111f8018fd65d3fc7e951c0039476c270e859bb6760836dcb40d
> curl -v -F "data=@$HOME/Pictures/blue_red_pill.jpg" http://localhost:3234/steem/205d8bcafb9e0e0897e2db330aa2bd1ca4f7764ad9b1ba04a2a9651453aee72f4a685bd631ad60111f8018fd65d3fc7e951c0039476c270e859bb6760836dcb40d
## Create a signature
......
......@@ -11,16 +11,15 @@ const requestPerHour = new RateLimit({duration: ms.hour, max: downloadIpLimit.re
const router = require('koa-router')()
router.get('/:type/:hash', function *() {
router.get('/:hash', function *() {
try {
const ip = getRemoteIp(this.req)
if(limit(this, requestPerHour, ip, 'Downloads', 'request')) return
if(missing(this, this.params, 'type')) return
if(missing(this, this.params, 'hash')) return
const {type, hash} = this.params
const key = `${type}/${hash}`
const {hash} = this.params
const key = `${hash}`
yield new Promise(resolve => {
const params = {Bucket: amazonBucket, Key: key};
......
......@@ -37,7 +37,7 @@ const requestDataRateLimits = [
new RateLimit({duration: ms.week, max: uploadDataLimit.megsPerWeek}),
]
router.post('/:type/:username/:signature', koaBody, function *() {
router.post('/:username/:signature', koaBody, function *() {
try {
const ip = getRemoteIp(this.req)
if(limit(this, requestIpRateLimits, ip, 'Uploads', 'request')) return
......@@ -45,18 +45,10 @@ router.post('/:type/:username/:signature', koaBody, function *() {
const {files, fields} = this.request.body
if(missing(this, files, 'data')) return
if(missing(this, this.params, 'type')) return
if(missing(this, this.params, 'username')) return
if(missing(this, this.params, 'signature')) return
// const {username} = fields
const {type} = this.params
if(type !== 'image') {
this.status = 404
this.statusText = `Unsupported type ${type}. Try using 'image'`
this.body = {error: this.statusText}
return
}
const {signature} = this.params
const sig = parseSig(signature)
......@@ -127,7 +119,7 @@ router.post('/:type/:username/:signature', koaBody, function *() {
return
}
const key = `${type}/${sha.toString('hex')}`
const key = sha.toString('hex')
const params = {Bucket: amazonBucket, Key: key, Body: dataBuffer};
s3.putObject(params, (err, data) => {
if(err) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment