diff --git a/README.md b/README.md
index 1dc7404a..a1edf905 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,12 @@
-
- Upup
-
+![upup_logo_dark](https://github.com/DevinoSolutions/upup/assets/43147238/b5477db9-cb23-43c7-8c12-518beb31af53)
- Easily handle your file upload needs. Easily integrate our API into your application to upload files to the cloud.
-
-Goodbye to nasty configs, painful APIs and hello to a simple, easy to use, file uploader.
-
+ An open-source, free-to-use NPM component that easily handles your file upload needs with seamless Google Drive and OneDrive integration.
+
-
+
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 30508c6f..735636dd 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -5698,7 +5698,7 @@ packages:
express: 4.18.2
fs-extra: 11.1.1
globby: 11.1.0
- ip: 2.0.0
+ ip: 2.0.1
lodash: 4.17.21
open: 8.4.2
pretty-hrtime: 1.0.3
@@ -11088,8 +11088,8 @@ packages:
loose-envify: 1.4.0
dev: true
- /ip@2.0.0:
- resolution: {integrity: sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==}
+ /ip@2.0.1:
+ resolution: {integrity: sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==}
dev: true
/ipaddr.js@1.9.1:
diff --git a/src/UpupUploader.tsx b/src/UpupUploader.tsx
index af7caa06..0586ad61 100644
--- a/src/UpupUploader.tsx
+++ b/src/UpupUploader.tsx
@@ -57,6 +57,7 @@ export interface UpupUploaderProps {
export type UploadFilesRef = {
uploadFiles: () => Promise
+ dynamicUploadFiles: (files: File[]) => Promise
}
/**
@@ -127,12 +128,20 @@ export const UpupUploader: FC> =
* Expose the handleUpload function to the parent component
*/
useImperativeHandle(ref, () => ({
+ async dynamicUploadFiles(dynamicFiles: File[]) {
+ if (dynamicFiles.length === 0) return null
+ return await this.proceedUpload(dynamicFiles)
+ },
async uploadFiles() {
if (files.length === 0) return null
const filesList =
mutatedFiles && mutatedFiles.length > 0
? mutatedFiles
: files
+ return await this.proceedUpload(filesList)
+ },
+
+ async proceedUpload(filesList: File[]) {
return new Promise(async (resolve, reject) => {
/**
* Check if the total size of files is less than the maximum size
@@ -149,13 +158,11 @@ export const UpupUploader: FC> =
),
)
}
-
/**
* Upload the file to the cloud storage
*/
let filesToUpload: File[]
let keys: string[] = []
-
/**
* Compress the file before uploading it to the cloud storage
*/
@@ -172,11 +179,9 @@ export const UpupUploader: FC> =
}),
)
else filesToUpload = filesList
-
/**
* Loop through the files array and upload the files
*/
-
if (filesToUpload) {
try {
filesToUpload.map(async file => {
diff --git a/src/version.ts b/src/version.ts
index c08297a0..9f8d6e47 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1 +1 @@
-export const LIB_VERSION = "2.3.4";
+export const LIB_VERSION = "2.3.6";
diff --git a/stories/Uploader.stories.tsx b/stories/Uploader.stories.tsx
index e1a676fd..1ff8ac84 100644
--- a/stories/Uploader.stories.tsx
+++ b/stories/Uploader.stories.tsx
@@ -1,6 +1,6 @@
import { CircularProgress } from '@mui/material'
import { Meta } from '@storybook/react'
-import { useRef } from 'react'
+import { useRef, useState } from 'react'
import {
UPLOAD_ADAPTER,
UploadAdapter,
@@ -19,8 +19,10 @@ const meta: Meta = {
export default meta
const Uploader = args => {
+ const [files, setFiles] = useState([])
const { baseConfigs, cloudStorageConfigs, googleConfigs, oneDriveConfigs } =
useUpup({
+ setFiles: setFiles,
accept: '*',
multiple: true,
limit: 5,
@@ -49,6 +51,16 @@ const Uploader = args => {
console.error('Error uploading files:', error)
}
}
+ const handleDynamicUpload = async () => {
+ try {
+ const testFiles: any[] = []
+ testFiles.push(files[0])
+ const data = await upupRef.current?.dynamicUploadFiles(testFiles)
+ console.log(`Upload ${data ? 'successful' : 'returned null.'} `)
+ } catch (error) {
+ console.error('Error uploading files:', error)
+ }
+ }
const loader =
@@ -64,7 +76,15 @@ const Uploader = args => {
loader={loader}
ref={upupRef}
/>
- Upload
+
+ Upload
+
+
+ Dynamic Upload
+
>
)
}