0.1.2 • Published 8 years ago

rc-upload-s3 v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

rc-upload-s3


React Upload S3

Usage

var Upload = require('rc-upload-s3');
var React = require('react');
var AWS = require('aws-sdk');
// use a valid credentials object from aws-sdk
var credentials = new AWS.CognitoIdentityCredentials({
  IdentityPoolId: '<identityPoolId>',
  IdentityId: '<IdentityId>',
  Logins: { 'cognito-identity.amazonaws.com': '<Token>' }
});
var s3params = {Metadata: { uploader: 'react-upload-s3' }}; // tag upload files with uploader used
React.render(<Upload action="bucketName" credentials={credentials} params={s3params} />, container);

API

props

nametypedefaultdescription
namestringfilefile param post to server
styleobject{}root component inline style
classNamestring-root component className
disabledbooleanfalsewhether disabled
component"div""span""span"
supportServerRenderbooleanfalsewhether to support server render
onReadyfunctiononly call when supportServerRender is true, upload is rendered completely
actionstringfrom action url
dataobject/function(file)other data object to post or a function which returns a data object
headersobject{}http headers to post, available in modern browsers
acceptstringinput accept attribute
multiplebooleanfalseonly support ie10+
onStartfunctionstart upload file
onErrorfunctionerror callback
onSuccessfunctionsuccess callback
onProgressfunctionprogress callback, only for modern browsers
beforeUploadfunctionnullbefore upload check, return false or a rejected Promise will stop upload, only for modern browsers
customRequestfunctionnullprovide an override for the default xhr behavior for additional customization
credentialsobject/functionnullshould resolve to AWS credential see aws-sdk docs
paramsobjectnullparams passed to AWS.S3({params: params}) see available param options
withCredentialsbooleanfalseajax upload with cookie send