@@ -56,13 +56,13 @@ Before you begin, make sure you have the following software installed:
5656Using npm:
5757
5858```
59- npm install @canopassoftware/vue -file-upload
59+ npm install @canopassoftware/react -file-upload
6060```
6161
6262Using yarn:
6363
6464```
65- yarn add @canopassoftware/vue -file-upload
65+ yarn add @canopassoftware/react -file-upload
6666```
6767
6868---
@@ -192,16 +192,26 @@ To manage and preview files with this library, follow these steps:
192192
193193```js
194194// using CommonJS
195- const { SingleFileUpload, MultipleFileUpload } = require("@canopassoftware/vue -file-upload");
195+ const { SingleFileUpload, MultipleFileUpload } = require("@canopassoftware/react -file-upload");
196196
197197OR
198198// using esModules
199- import { SingleFileUpload, MultipleFileUpload } from "@canopassoftware/vue -file-upload";
199+ import { SingleFileUpload, MultipleFileUpload } from "@canopassoftware/react -file-upload";
200200```
201201
202202### Creating custom UI with file preview
203203
204204- You can customize file uploading UI in inner part of component.
205+ - The ` file ` containing ` file ` object with following keys, we will use this object to show preview.
206+
207+ ``` js
208+ file = file: {
209+ previewType: ' video' , // type of the preview. like, file is image or video
210+ previewUrl: ' data:image/jpeg;base64,/9j/D1AAAACRsdW1pAAAD...' , // URL of the file preview
211+ previewName: ' a152148640581.62d918f12a0b4.mp4' , // preview file name
212+ isDragging: false // you will get it `true` when you dragging the file on design
213+ }
214+ ```
205215
206216### Single File Upload Management
207217
@@ -210,7 +220,7 @@ import { SingleFileUpload, MultipleFileUpload } from "@canopassoftware/vue-file-
210220
211221import Image from " next/image" ;
212222import React , { useState } from " react" ;
213- import { SingleFileUpload } from ' @canopassoftware/vue -file-upload' ;
223+ import { SingleFileUpload } from ' @canopassoftware/react -file-upload' ;
214224
215225export default function App () {
216226 const [previewFileData , setPreviewFileData ] = useState (
@@ -222,6 +232,7 @@ export default function App() {
222232 }
223233 );
224234
235+ // callback function
225236 const handleFileUploading = async (file : any ) => {
226237 await new Promise ((resolve ) => setTimeout (resolve, 2000 ));
227238 setPreviewFileData ({
@@ -242,12 +253,66 @@ export default function App() {
242253 uploadBtn= {" Save" }
243254 progressBtn= {" Saving..." }
244255 >
256+ <!-- write a code to manage file design or use code from examples -->
245257 < / SingleFileUpload>
246258 < / main>
247259 );
248260}
249261```
250262
263+ ### Multiple File Upload Management
264+
265+ ``` js
266+ " use client" ;
267+
268+ import Image from " next/image" ;
269+ import React from " react" ;
270+ import MultipleFileUpload from " @canopassoftware/react-file-upload" ;
271+ import { StaticImageData } from " next/image" ;
272+
273+ export default function App () {
274+ const uploadedFiles = [] as Array < {
275+ fileType: string;
276+ fileUrl: string | StaticImageData;
277+ fileName: string;
278+ }> ;
279+
280+ // callback function
281+ const handleFilesUploading = async (files : any ) => {
282+ const uploadedFiles = [];
283+
284+ for (var i = 0 ; i < files .length ; i++ ) {
285+ uploadedFiles .push ({
286+ fileType: " image" ,
287+ fileUrl: images[i],
288+ fileName: files[i].name ,
289+ });
290+ }
291+
292+ await new Promise ((resolve ) => setTimeout (resolve, 5000 ));
293+ return uploadedFiles;
294+ };
295+ ` ` `
296+
297+ ` ` ` html
298+ return (
299+ < main className= " min-h-screen flex flex-col justify-between p-5 dark:bg-black" >
300+ < MultipleFileUpload
301+ accept= " "
302+ uploadedFiles= {uploadedFiles}
303+ callback= {handleFilesUploading}
304+ uploadBtn= {" Save" }
305+ progressBtn= {" Saving..." }
306+ >
307+ {(file : any ) => (
308+ <!-- write a code to manage file design or use code from examples -->
309+ )}
310+ < / MultipleFileUpload>
311+ < / main>
312+ );
313+ }
314+ ```
315+
251316## Contributing
252317
253318We welcome contributions from the community. To contribute to this project, please follow these guidelines:
0 commit comments