react-s3-uploader
Advanced tools
Comparing version 1.1.5 to 1.1.6
{ | ||
"name": "react-s3-uploader", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "React component that renders a file input and automatically uploads to an S3 bucket", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,3 +39,3 @@ react-s3-uploader | ||
----------- | ||
### Bundled router | ||
You can use the Express router that is bundled with this module to answer calls to `/s3/sign` | ||
@@ -54,1 +54,23 @@ | ||
The `aws-sdk` must be configured with your account's Access Key and Secret Access Key. [There are a number of ways to provide these](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html), but setting up environment variables is the quickest. You just have to configure environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, and AWS automatically picks them up. | ||
### Boto for Python, in a Django project | ||
import boto | ||
import mimetypes | ||
import json | ||
... | ||
conn = boto.connect_s3('AWS_KEY', 'AWS_SECRET') | ||
def sign_s3_upload(request): | ||
object_name = request.GET['objectName'] | ||
content_type = mimetypes.guess_type(object_name)[0] | ||
signed_url = conn.generate_url( | ||
300, | ||
"PUT", | ||
'BUCKET_NAME', | ||
'FOLDER_NAME' + object_name, | ||
headers = {'Content-Type': content_type, 'x-amz-acl':'public-read'}) | ||
return HttpResponse(json.dumps({'signedUrl': signed_url})) |
@@ -62,3 +62,4 @@ /** | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('GET', this.signingUrl + '?objectName=' + file.name, true); | ||
var fileName = file.name.replace(/[^\w]/g, "_"); | ||
xhr.open('GET', this.signingUrl + '?objectName=' + fileName, true); | ||
xhr.overrideMimeType && xhr.overrideMimeType('text/plain; charset=x-user-defined'); | ||
@@ -65,0 +66,0 @@ xhr.onreadystatechange = function() { |
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
11331
200
74