Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
react-s3-uploader
Advanced tools
React component that renders an and automatically uploads to an S3 bucket
Provides a React
component that automatically uploads to an S3 Bucket.
$ npm install react-s3-uploader
var ReactS3Uploader = require('react-s3-uploader');
...
<ReactS3Uploader
signingUrl="/s3/sign"
accept="image/*"
onProgress={this.onUploadProgress}
onError={this.onUploadError}
onFinish={this.onUploadFinish}/>
The above example shows all supported props
.
This expects a request to /s3/sign
to return JSON with a signedUrl
property that can be used
to PUT the file in S3.
The resulting DOM is essentially:
<input type="file" onChange={this.uploadFile} />
When a file is chosen, it will immediately be uploaded to S3. You can listen for progress (and
create a status bar, for example) by providing an onProgress
function to the component.
You can use the Express router that is bundled with this module to answer calls to /s3/sign
app.use('/s3', require('react-s3-uploader/s3router')({
bucket: "MyS3Bucket"
}));
This also provides another endpoint: GET /s3/img/(.*)
. This will create a temporary URL
that provides access to the uploaded file (which are uploaded privately at the moment). The
request is then redirected to the URL, so that the image is served to the client.
You must provide environment variables AWS_ACCESS_KEY_ID
and AWS_SECRET_KEY
to use the server route.
FAQs
React component that renders a file input and automatically uploads to an S3 bucket
The npm package react-s3-uploader receives a total of 28,363 weekly downloads. As such, react-s3-uploader popularity was classified as popular.
We found that react-s3-uploader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.