react-s3-uploader
Advanced tools
Comparing version 1.1.14 to 1.1.15
{ | ||
"name": "react-s3-uploader", | ||
"version": "1.1.14", | ||
"version": "1.1.15", | ||
"description": "React component that renders a file input and automatically uploads to an S3 bucket", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,4 @@ "use strict"; | ||
signingUrlQueryParams: React.PropTypes.object, | ||
uploadRequestHeaders: React.PropTypes.object | ||
uploadRequestHeaders: React.PropTypes.object, | ||
contentDisposition: React.PropTypes.string | ||
}, | ||
@@ -43,3 +44,4 @@ | ||
signingUrlQueryParams: this.props.signingUrlQueryParams, | ||
uploadRequestHeaders: this.props.uploadRequestHeaders | ||
uploadRequestHeaders: this.props.uploadRequestHeaders, | ||
contentDisposition: this.props.contentDisposition | ||
}); | ||
@@ -46,0 +48,0 @@ }, |
@@ -26,3 +26,4 @@ react-s3-uploader | ||
signingUrlQueryParams={{ additional: query-params }} | ||
uploadRequestHeaders={{ 'x-amz-acl', 'public-read' }} /> | ||
uploadRequestHeaders={{ 'x-amz-acl', 'public-read' }} | ||
contentDisposition="auto" /> | ||
@@ -34,2 +35,7 @@ The above example shows all supported `props`. For `uploadRequestHeaders`, the default ACL is shown. | ||
`contentDisposition` is optional and can be one of `inline`, `attachment` or `auto`. If given, | ||
the `Content-Disposition` header will be set accordingly with the file's original filename. | ||
If it is `auto`, the disposition type will be set to `inline` for images and `attachment` for | ||
all other files. | ||
The resulting DOM is essentially: | ||
@@ -36,0 +42,0 @@ |
@@ -122,2 +122,14 @@ /** | ||
xhr.setRequestHeader('Content-Type', file.type); | ||
if (this.contentDisposition) { | ||
var disposition = this.contentDisposition; | ||
if (disposition === 'auto') { | ||
if (file.type.substr(0, 6) === 'image/') { | ||
disposition = 'inline'; | ||
} else { | ||
disposition = 'attachment'; | ||
} | ||
} | ||
var fileName = file.name.replace(/\s+/g, "_"); | ||
xhr.setRequestHeader('Content-Disposition', disposition + '; filename=' + fileName); | ||
} | ||
if (this.uploadRequestHeaders) { | ||
@@ -124,0 +136,0 @@ var uploadRequestHeaders = this.uploadRequestHeaders; |
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
15156
263
112