react-s3-uploader
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "react-s3-uploader", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "React component that renders a file input and automatically uploads to an S3 bucket", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,3 +17,4 @@ "use strict"; | ||
uploadRequestHeaders: React.PropTypes.object, | ||
contentDisposition: React.PropTypes.string | ||
contentDisposition: React.PropTypes.string, | ||
server: React.PropTypes.string | ||
}, | ||
@@ -31,3 +32,4 @@ | ||
console.log("Upload error: " + message); | ||
} | ||
}, | ||
server: '' | ||
}; | ||
@@ -46,3 +48,4 @@ }, | ||
uploadRequestHeaders: this.props.uploadRequestHeaders, | ||
contentDisposition: this.props.contentDisposition | ||
contentDisposition: this.props.contentDisposition, | ||
server: this.props.server | ||
}); | ||
@@ -49,0 +52,0 @@ }, |
@@ -27,3 +27,4 @@ react-s3-uploader | ||
uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }} | ||
contentDisposition="auto" /> | ||
contentDisposition="auto" | ||
server="http://cross-origin-server.com" /> | ||
@@ -40,2 +41,6 @@ The above example shows all supported `props`. For `uploadRequestHeaders`, the default ACL is shown. | ||
`server` is optional and can be used to specify the location of the server which is | ||
running the ReactS3Uploader server component if it is not the same as the one from | ||
which the client is served. | ||
The resulting DOM is essentially: | ||
@@ -56,2 +61,3 @@ | ||
region: 'us-east-1', //optional | ||
headers: {'Access-Control-Allow-Origin': '*'}, // optional | ||
ACL: 'private' // this is default | ||
@@ -120,2 +126,8 @@ })); | ||
##### 1.2.1 | ||
* Added `server` prop to `ReactS3Uploader` to support running the signing server on a different domain | ||
* Added `headers` option to `s3router` to support specifying `'Access-Control-Allow-Origin'` header (or any others) | ||
* [Fixes #44] Using `unorm.nfc(str)` in favor of `str.normalize()` | ||
##### 1.2.0 | ||
@@ -122,0 +134,0 @@ |
@@ -65,2 +65,6 @@ | ||
var fileKey = checkTrailingSlash(getFileKeyDir(req)) + filename; | ||
// Set any custom headers | ||
if (options.headers) { | ||
res.set(options.headers); | ||
} | ||
@@ -67,0 +71,0 @@ var s3 = new aws.S3(); |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
var latinize = require('latinize'), | ||
@@ -66,4 +66,3 @@ unorm = require('unorm'); | ||
S3Upload.prototype.executeOnSignedUrl = function(file, callback) { | ||
var xhr = new XMLHttpRequest(); | ||
var normalizedFileName = file.name.replace(/\s+/g, "_").normalize(); | ||
var normalizedFileName = unorm.nfc(file.name.replace(/\s+/g, "_")); | ||
var fileName = latinize(normalizedFileName); | ||
@@ -78,3 +77,4 @@ var queryString = '?objectName=' + fileName + '&contentType=' + file.type; | ||
} | ||
xhr.open('GET', this.signingUrl + queryString, true); | ||
var xhr = this.createCORSRequest('GET', | ||
this.server + this.signingUrl + queryString); | ||
if (this.signingUrlHeaders) { | ||
@@ -139,3 +139,3 @@ var signingUrlHeaders = this.signingUrlHeaders; | ||
} | ||
var normalizedFileName = file.name.replace(/\s+/g, "_").normalize(); | ||
var normalizedFileName = unorm.nfc(file.name.replace(/\s+/g, "_")); | ||
var fileName = latinize(normalizedFileName); | ||
@@ -142,0 +142,0 @@ xhr.setRequestHeader('Content-Disposition', disposition + '; filename=' + fileName); |
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
17387
300
133