4343
4444<h1 align =" center " >
4545 Quick Start —
46- <a href =" https://codepen.io/upload-js/pen/popWJpX?editors=1010 " >
46+ <a href =" https://codepen.io/upload-js/pen/popWJpX?editors=0010 " >
4747 Try on CodePen
4848 </a >
4949</h1 >
@@ -96,39 +96,35 @@ Or via a `<script>` tag:
9696<script src =" https://js.upload.io/react-uploader/v2" ></script >
9797```
9898
99- # Usage
100-
101- Initialize once at the start of your application:
102-
103- ``` javascript
104- import { Uploader } from " uploader" ;
105-
106- // Get production API keys from Upload.io
107- const uploader = Uploader ({
108- apiKey: " free"
109- });
110- ```
111-
112- Then choose a UI component:
113-
114- ## ` UploadButton `
99+ ## UploadButton — [ Try on CodePen] ( https://codepen.io/upload-js/pen/popWJpX?editors=0010 )
115100
116101The ` UploadButton ` component uses a [ render prop] ( https://reactjs.org/docs/render-props.html ) to provide an ` onClick ` callback to your button element.
117102
118103When clicked, a file upload modal will appear:
119104
120105``` javascript
106+ import { Uploader } from " uploader" ; // Installed by "react-uploader".
121107import { UploadButton } from " react-uploader" ;
122108
123- < UploadButton uploader= {uploader}
124- options= {{multi: true }}
125- onComplete= {files => console .log (files)}>
126- {({onClick}) =>
127- < button onClick= {onClick}>
128- Upload a file...
129- < / button>
130- }
131- < / UploadButton>
109+ // Initialize once (at the start of your app).
110+ const uploader = Uploader ({
111+ apiKey: " free" // Get production API keys from Upload.io
112+ });
113+
114+ // Configuration options: https://upload.io/uploader#customize
115+ const options = { multi: true };
116+
117+ const MyApp = () => (
118+ < UploadButton uploader= {uploader}
119+ options= {options}
120+ onComplete= {files => alert (files .map (x => x .fileUrl ).join (" \n " ))}>
121+ {({onClick}) =>
122+ < button onClick= {onClick}>
123+ Upload a file...
124+ < / button>
125+ }
126+ < / UploadButton>
127+ );
132128```
133129
134130Required props:
@@ -139,20 +135,30 @@ Optional props:
139135- ` options `
140136- ` onComplete `
141137
142- ## ` UploadDropzone `
138+ ## UploadDropzone — [ Try on CodePen ] ( https://codepen.io/upload-js/pen/LYrMzaB?editors=0010 )
143139
144140The ` UploadDropzone ` component renders an inline drag-and-drop file upload dropzone:
145141
146142``` javascript
147- import { UploadDropzone } from " react-uploader" ;
143+ import { Uploader } from " uploader" ; // Installed by "react-uploader".
144+ import { UploadButton } from " react-uploader" ;
148145
149- < UploadDropzone uploader= {uploader}
150- options= {{multi: true }}
151- onUpdate= {files => console .log (files)}
152- width= " 600px"
153- height= " 375px" / >
154- ```
146+ // Initialize once (at the start of your app).
147+ const uploader = Uploader ({
148+ apiKey: " free" // Get production API keys from Upload.io
149+ });
150+
151+ // Configuration options: https://upload.io/uploader#customize
152+ const options = { multi: true };
155153
154+ const MyApp = () => (
155+ < UploadDropzone uploader= {uploader}
156+ options= {options}
157+ onUpdate= {files => alert (files .map (x => x .fileUrl ).join (" \n " ))}
158+ width= " 600px"
159+ height= " 375px" / >
160+ );
161+ ```
156162
157163Required props:
158164- ` uploader `
@@ -214,7 +220,7 @@ Upload.io benefits developers with:
214220
215221### 🔧 Can I bring my own file storage?
216222
217- Uploader's USP is to provide the fastest way to integrate end-to-end file uploads into a web app, while remaining customizable. As such, Uploader will always be closely integrated with the Upload.io platform, and there are currently no plans to support custom backends . You may, however, sync files from your Upload.io account to a custom storage target .
223+ ** Yes! ** [ Upload.io] ( https://upload.io ) supports custom S3 buckets . You are still required to create an account .
218224
219225## Contribute
220226
0 commit comments