react-s3-uploader
Advanced tools
Comparing version 4.2.0 to 4.3.0
##### 4.3.0 | ||
* Support middleware in express module with optional second arg | ||
* Allow 200 or 201 for success on sign request | ||
##### 4.2.0 | ||
@@ -3,0 +8,0 @@ |
{ | ||
"name": "react-s3-uploader", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "React component that renders a file input and automatically uploads to an S3 bucket", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,3 @@ react-s3-uploader | ||
contentDisposition="auto" | ||
scrubFilename={(filename) => filename.replace(/[^\w\d_\-\.]+/ig, '')} | ||
scrubFilename={(filename) => filename.replace(/[^\w\d_\-.]+/ig, '')} | ||
server="http://cross-origin-server.com" /> | ||
@@ -35,0 +35,0 @@ ``` |
@@ -13,4 +13,8 @@ var uuidv4 = require('uuid/v4'), | ||
function S3Router(options) { | ||
function S3Router(options, middleware) { | ||
if (!middleware) { | ||
middleware = []; | ||
} | ||
var S3_BUCKET = options.bucket, | ||
@@ -54,3 +58,3 @@ getFileKeyDir = options.getFileKeyDir || function() { return ""; }; | ||
*/ | ||
router.get(/\/img\/(.*)/, function(req, res) { | ||
router.get(/\/img\/(.*)/, middleware, function(req, res) { | ||
return tempRedirect(req, res); | ||
@@ -62,3 +66,3 @@ }); | ||
*/ | ||
router.get(/\/uploads\/(.*)/, function(req, res) { | ||
router.get(/\/uploads\/(.*)/, middleware, function(req, res) { | ||
return tempRedirect(req, res); | ||
@@ -71,3 +75,3 @@ }); | ||
*/ | ||
router.get('/sign', function(req, res) { | ||
router.get('/sign', middleware, function(req, res) { | ||
var filename = (options.uniquePrefix ? uuidv4() + "_" : "") + req.query.objectName; | ||
@@ -74,0 +78,0 @@ var mimeType = req.query.contentType; |
@@ -9,2 +9,3 @@ /** | ||
S3Upload.prototype.signingUrlMethod = 'GET'; | ||
S3Upload.prototype.signingUrlSuccessResponses = [200, 201]; | ||
S3Upload.prototype.fileElement = null; | ||
@@ -100,3 +101,3 @@ S3Upload.prototype.files = null; | ||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState === 4 && xhr.status === 200) { | ||
if (xhr.readyState === 4 && this.signingUrlSuccessResponses.indexOf(xhr.status) >= 0) { | ||
var result; | ||
@@ -110,3 +111,3 @@ try { | ||
return callback(result); | ||
} else if (xhr.readyState === 4 && xhr.status !== 200) { | ||
} else if (xhr.readyState === 4 && this.signingUrlSuccessResponses.indexOf(xhr.status) < 0) { | ||
return this.onError('Could not contact request signing server. Status = ' + xhr.status, file); | ||
@@ -113,0 +114,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24738
368