Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-s3-uploader

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-s3-uploader - npm Package Compare versions

Comparing version 1.1.11 to 1.1.12

3

package.json
{
"name": "react-s3-uploader",
"version": "1.1.11",
"version": "1.1.12",
"description": "React component that renders a file input and automatically uploads to an S3 bucket",

@@ -28,3 +28,2 @@ "main": "index.js",

"aws-sdk": "2.x",
"mime": "1.x",
"node-uuid": "1.x",

@@ -31,0 +30,0 @@ "object-assign": "^2.0.0"

@@ -48,3 +48,3 @@ react-s3-uploader

This also provides another endpoint: `GET /s3/img/(.*)`. This will create a temporary URL
This also provides another endpoint: `GET /s3/img/(.*)` and `GET /s3/uploads/(.*)`. This will create a temporary URL
that provides access to the uploaded file (which are uploaded privately at the moment). The

@@ -80,5 +80,25 @@ request is then redirected to the URL, so that the image is served to the client.

return HttpResponse(json.dumps({'signedUrl': signed_url}))
#### Ruby on Rails, assuming FOG usage
# Usual fog config, set as an initializer
FOG = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
})
# In the controller
options = {path_style: true}
headers = {"Content-Type" => params[:contentType], "x-amz-acl" => "public-read"}
@url = FOG.put_object_url(ENV['S3_BUCKET_NAME'], "user_uploads/#{params[:objectName]}", 15.minutes.from_now.to_time.to_i, headers, options)
respond_to do |format|
format.json { render json: {signedUrl: @url} }
end
##### Other Servers
If you do some work on another server, and would love to contribute documentation, please send us a PR!
var mime = require('mime'),
uuid = require('node-uuid'),
aws = require('aws-sdk'),
express = require('express');
var uuid = require('node-uuid'),
aws = require('aws-sdk'),
express = require('express');

@@ -31,5 +30,5 @@

* Redirects image requests with a temporary signed URL, giving access
* to GET an image.
* to GET an upload.
*/
router.get(/\/img\/(.*)/, function(req, res) {
function tempRedirect(req, res) {
var params = {

@@ -43,5 +42,19 @@ Bucket: S3_BUCKET,

});
};
/**
* Image specific route.
*/
router.get(/\/img\/(.*)/, function(req, res) {
return tempRedirect(req, res);
});
/**
* Other file type(s) route.
*/
router.get(/\/uploads\/(.*)/, function(req, res) {
return tempRedirect(req, res);
});
/**
* Returns an object with `signedUrl` and `publicUrl` properties that

@@ -52,3 +65,3 @@ * give temporary access to PUT an object in an S3 bucket.

var filename = uuid.v4() + "_" + req.query.objectName;
var mimeType = mime.lookup(filename);
var mimeType = req.query.contentType;
var fileKey = checkTrailingSlash(getFileKeyDir(req)) + filename;

@@ -71,3 +84,3 @@

signedUrl: data,
publicUrl: '/s3/img/' + filename,
publicUrl: '/s3/uploads/' + filename,
filename: filename

@@ -74,0 +87,0 @@ });

@@ -63,3 +63,3 @@ /**

var fileName = file.name.replace(/\s+/g, "_");
xhr.open('GET', this.signingUrl + '?objectName=' + fileName, true);
xhr.open('GET', this.signingUrl + '?objectName=' + fileName + '&contentType=' + file.type, true);
xhr.overrideMimeType && xhr.overrideMimeType('text/plain; charset=x-user-defined');

@@ -66,0 +66,0 @@ xhr.onreadystatechange = function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc