Socket
Socket
Sign inDemoInstall

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 4.5.0 to 4.5.1

4

CHANGELOG.md
##### 4.5.1
* Add `inputRef` prop [#153]
##### 4.5.0

@@ -3,0 +7,0 @@

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -33,3 +33,4 @@ "use strict";

scrubFilename: PropTypes.func,
s3path: PropTypes.string
s3path: PropTypes.string,
inputRef: PropTypes.func
},

@@ -95,3 +96,10 @@

getInputProps: function() {
var temporaryProps = objectAssign({}, this.props, {type: 'file', onChange: this.uploadFile});
// declare ref beforehand and filter out
// `inputRef` by `ReactS3Uploader.propTypes`
var additional = {
type: 'file',
onChange: this.uploadFile,
ref: this.props.inputRef
};
var temporaryProps = objectAssign({}, this.props, additional);
var inputProps = {};

@@ -98,0 +106,0 @@

@@ -185,5 +185,52 @@ react-s3-uploader

#### [Micro](https://github.com/zeit/micro)
```javascript
const aws = require('aws-sdk')
const uuidv4 = require('uuid/v4')
const { createError } = require('micro')
const options = {
bucket: 'S3_BUCKET_NAME',
region: 'S3_REGION',
signatureVersion: 'v4',
ACL: 'public-read'
}
const s3 = new aws.S3(options)
module.exports = (req, res) => {
const originalFilename = req.query.objectName
// custom filename using random uuid + file extension
const fileExtension = originalFilename.split('.').pop()
const filename = `${uuidv4()}.${fileExtension}`
const params = {
Bucket: options.bucket,
Key: filename,
Expires: 60,
ContentType: req.query.contentType,
ACL: options.ACL
}
const signedUrl = s3.getSignedUrl('putObject', params)
if (signedUrl) {
// you may also simply return the signed url, i.e. `return { signedUrl }`
return {
signedUrl,
filename,
originalFilename,
publicUrl: signedUrl.split('?').shift()
}
} else {
throw createError(500, 'Cannot create S3 signed URL')
}
}
```
##### Other Servers
If you do some work on another server, and would love to contribute documentation, please send us a PR!
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