# @bassem97/upup

> README.md

Latest version **2.4.0** (published 2024-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bassem97/upup
pnpm add @bassem97/upup
yarn add @bassem97/upup
bun add @bassem97/upup
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.4.0 |
| Published | 2024-03-06 |
| First published | 2023-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 12 |
| Unpacked size | 781.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Bassem Jadoui |
| Maintainers | bassem97 |
| Keywords | react, typescript, aws/sdk, s3, file, uploader, react-uploader, one-drive, google-drive, pako, gzip, compress, decompress |

## Links

- npm: https://www.npmjs.com/package/@bassem97/upup
- Repository: https://github.com/uNotesOfficial/upup
- Homepage: https://github.com/uNotesOfficial/upup#readme
- Issues: https://github.com/uNotesOfficial/upup/issues
- npm.io page: https://npm.io/package/@bassem97/upup

## Dependencies (12)

- [uuid](https://npm.io/package/uuid.md) ^9.0.1
- [@types/gapi](https://npm.io/package/@types/gapi.md) ^0.0.47
- [load-script](https://npm.io/package/load-script.md) ^2.0.0
- [react-icons](https://npm.io/package/react-icons.md) ^4.12.0
- [react-webcam](https://npm.io/package/react-webcam.md) ^7.2.0
- [@mui/material](https://npm.io/package/@mui/material.md) ^5.14.18
- [framer-motion](https://npm.io/package/framer-motion.md) ^10.16.5
- [@emotion/styled](https://npm.io/package/@emotion/styled.md) ^11.11.0
- [@aws-sdk/client-s3](https://npm.io/package/@aws-sdk/client-s3.md) ^3.458.0
- [@azure/msal-browser](https://npm.io/package/@azure/msal-browser.md) ^3.5.0
- [@aws-sdk/xhr-http-handler](https://npm.io/package/@aws-sdk/xhr-http-handler.md) ^3.451.0
- [babel-plugin-module-resolver](https://npm.io/package/babel-plugin-module-resolver.md) ^5.0.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.4.0 (latest) — 2024-03-06
- 2.3.6 — 2023-12-06
- 2.3.5 — 2023-12-04
- 2.3.4 — 2023-11-27
- 2.3.3 — 2023-11-18
- 2.3.2 — 2023-11-18
- 2.3.1 — 2023-11-07
- 2.3.0 — 2023-11-01
- 2.2.31 — 2023-10-31
- 2.2.30 — 2023-10-28
- 2.2.29 — 2023-10-23
- 2.2.28 — 2023-10-22
- 2.2.27 — 2023-10-22
- 2.2.26 — 2023-10-20
- 2.2.25 — 2023-10-19
- … 83 more at https://npm.io/package/@bassem97/upup/versions

## README

![upup_logo_dark](https://github.com/DevinoSolutions/upup/assets/43147238/b5477db9-cb23-43c7-8c12-518beb31af53)

<br/>

<div align="center">
   An open-source, free-to-use NPM component that easily handles your file upload needs with seamless Google Drive and OneDrive integration.
   
</div>
<br/>
<p align="center">
  <a href="https://github.com/uNotesOfficial/upup">
    <img src="https://img.shields.io/badge/gzipped-206kb-4ba0f6" />
  </a>

<hr/>
<br />

## Installation

Install via NPM:

```shell
npm install @bassem97/upup
```

Or via YARN:

```shell
yarn add @bassem97/upup
```

## Usage

### 1 - Inside you component or App.tsx import UpupUploader and the types you need :

```javascript
// imports
import {
    BaseConfigs,
    CloudStorageConfigs,
    GoogleConfigs,
    OneDriveConfigs,
    Is3Configs,
    UploadAdapter,
    UpupUploader,
} from '@bassem97/upup'
```

### 2 - Set your configurations keys from your .env file ( ex: .env.local ) :

```javascript
const space_secret = process.env.SPACE_SECRET
const space_key = process.env.SPACE_KEY
const space_endpoint = process.env.SPACE_ENDPOINT
const space_region = process.env.SPACE_REGION
const document_space = process.env.SPACE_DOCUMENTS
const image_space = process.env.SPACE_IMAGES
const onedrive_client_id = process.env.ONEDRIVE_CLIENT_ID
const google_client_id = process.env.GOOGLE_CLIENT_ID
const google_app_id = process.env.GOOGLE_APP_ID
const google_api_key = process.env.GOOGLE_API_KEY
```

### 3 - Create 2 states one for key (which will be the final link of you file. ex: 'https://example-documents.nyc3.cdn.digitaloceanspaces.com/file.pdf') and another for canUpload ( which will be changed after uploading file and submitting )

```javascript
const [key, setKey] = useState('')
const [canUpload, setCanUpload] = useState(false)
```

### 4 - initialize the configs from the provider you want to use ( ex: DigitalOceanSpaces, GoogleDriveUploader, OneDriveUploader, S3 )

```javascript
const s3Configs: S3Configs = {
    region: space_region,
    endpoint: space_endpoint,
    credentials: {
        accessKeyId: space_key,
        secretAccessKey: space_secret,
    },
}

const baseConfigs: BaseConfigs = {
    canUpload: canUpload,
    setKey: setKey,
}

const cloudStorageConfigs: CloudStorageConfigs = {
    bucket: document_space,
    s3Configs,
}

const googleConfigs: GoogleConfigs = {
    google_api_key,
    google_app_id,
    google_client_id,
}

const oneDriveConfigs: OneDriveConfigs = {
    onedrive_client_id,
    multiSelect: false,
}
```

### 4 - Render the UpupUploader component and pass the configs and the adapter you want to use :

```javascript
return (
    <div>
        <UpupUploader
            baseConfigs={baseConfigs}
            cloudStorageConfigs={cloudStorageConfigs}
            googleConfigs={googleConfigs}
            oneDriveConfigs={oneDriveConfigs}
            uploadAdapters={[
                UploadAdapter.INTERNAL,
                UploadAdapter.GOOGLE_DRIVE,
                UploadAdapter.ONE_DRIVE,
            ]}
        />
        <button onClick={() => setCanUpload(true)}> upload </button>
    </div>
)
```

### 5 - You can also use the UpupUploader component with the default configs and adapter :

```javascript
return (
    <div>
        <UpupUploader
            baseConfigs={baseConfigs}
            cloudStorageConfigs={cloudStorageConfigs}
            uploadAdapters={[UploadAdapter.internal]}
        />
        <button onClick={() => setCanUpload(true)}> upload </button>
    </div>
)
```

## All done! 🎉

### Contributions

Contributions to this project are welcome! Feel free to submit issues or pull requests on the [GitHub repository](https://github.com/uNotesOfficial/upup.git).

---
_Source: https://npm.io/package/@bassem97/upup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
