|
| 1 | +<a href="https://gauthamvijay.com"> |
| 2 | + <picture> |
| 3 | + <img alt="react-native-nitro-cloud-uploader" src="./docs/img/banner.png" /> |
| 4 | + </picture> |
| 5 | +</a> |
| 6 | + |
| 7 | +# react-native-nitro-cloud-uploader (Beta) |
| 8 | + |
| 9 | +**React Native Nitro Module** for **reliable, resumable, background-friendly uploads** of large files (audio, video, images, PDFs) to **S3-compatible storage** — built for real production workloads. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +> [!NOTE] |
| 14 | +> |
| 15 | +> - This library was originally created for my production app, where we needed to upload **long audio recordings** and large media files directly from the device — reliably, even when the app was in the background. |
| 16 | +> - It works great with **multipart presigned URLs** for: |
| 17 | +> - Cloudflare R2 |
| 18 | +> - Backblaze B2 |
| 19 | +> - Any S3-compatible bucket |
| 20 | +> - I haven't tested AWS S3 yet, but it should work without changes. |
| 21 | +> |
| 22 | +> If you need mobile uploads of **huge files** to S3-compatible storage, this library gives you everything you need out of the box. |
| 23 | +
|
| 24 | +--- |
| 25 | + |
| 26 | +## 📦 Installation |
| 27 | + |
| 28 | +```bash |
| 29 | +npm install react-native-nitro-cloud-uploader react-native-nitro-modules |
| 30 | +``` |
| 31 | + |
| 32 | +> [!IMPORTANT] |
| 33 | +> |
| 34 | +> - All of my users are on **iOS in the US**, so iOS support is complete. |
| 35 | +> - Android support is **not fully implemented yet andd does not work and should not used for now!**. |
| 36 | +> - PRs for Kotlin / Android support are absolutely welcome! |
| 37 | +
|
| 38 | +--- |
| 39 | + |
| 40 | +## 🎥 Demo |
| 41 | + |
| 42 | +<table> |
| 43 | + <tr> |
| 44 | + <th align="center">🍏 iOS Demo</th> |
| 45 | + </tr> |
| 46 | + <tr> |
| 47 | + <td align="center"> |
| 48 | + <img src="./docs/videos/iOS.gif" width="300" alt="Demo GIF" /> |
| 49 | + </td> |
| 50 | + </tr> |
| 51 | +</table> |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +> [!NOTE] |
| 56 | +> |
| 57 | +> S3 multipart **PUT** uploads require a **minimum chunk size of 5 MB**, so this library defaults to splitting files into 5 MB parts to prevent upload issues. |
| 58 | +> |
| 59 | +> You must implement your own backend endpoint to generate the multipart presigned URLs. Once provided, the library automatically handles uploading each part and storing the returned **ETag** values for you. |
| 60 | +> Demo showcases uploading to cloudflare R2 Bucket |
| 61 | +
|
| 62 | +```tsx |
| 63 | +const BASE_URL = 'https://api.uploader.com/file-uploader'; |
| 64 | +const CREATE_UPLOAD_URL = `${BASE_URL}/create-and-start-upload`; |
| 65 | +const COMPLETE_UPLOAD_URL = `${BASE_URL}/complete-upload`; |
| 66 | +const ABORT_UPLOAD_URL = `${BASE_URL}/abort-upload`; |
| 67 | +``` |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## 🧠 Overview |
| 72 | + |
| 73 | +| Feature | Support | |
| 74 | +| --------------------------------- | -------------- | |
| 75 | +| Large file uploads (audio/video) | ✅ | |
| 76 | +| Multipart / presigned URL uploads | ✅ | |
| 77 | +| Cloudflare R2 | ✅ | |
| 78 | +| Backblaze B2 | ✅ | |
| 79 | +| S3-compatible storage | ✅ | |
| 80 | +| Background upload (iOS) | ✅ | |
| 81 | +| Progress tracking | ✅ | |
| 82 | +| Kotlin Android support | 🚧 PRs welcome | |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## ⚙️ Basic Usage |
| 87 | + |
| 88 | +```tsx |
| 89 | +import CloudUploader from 'react-native-nitro-cloud-uploader'; |
| 90 | + |
| 91 | +const createResponse = await fetch(CREATE_UPLOAD_URL, { |
| 92 | + method: 'POST', |
| 93 | + headers: { 'Content-Type': 'application/json' }, |
| 94 | + body: JSON.stringify({ |
| 95 | + uploadId: newUploadId, |
| 96 | + fileSize, |
| 97 | + chunkSize: 6 * 1024 * 1024, // 6MB chunks |
| 98 | + }), |
| 99 | +}); |
| 100 | + |
| 101 | +await CloudUploader.startUpload(newUploadId, filePath, uploadUrls, 3, true); |
| 102 | +``` |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## 🧩 Supported Platforms |
| 107 | + |
| 108 | +| Platform | Status | |
| 109 | +| ----------------- | ------------------------------ | |
| 110 | +| **iOS** | ✅ Fully Supported | |
| 111 | +| **Android** | 🚧 Does not work (PRs welcome) | |
| 112 | +| **iOS Simulator** | ✅ Works | |
| 113 | +| **AOSP Emulator** | 🚧 Does not work (PRs welcome) | |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## 🤝 Contributing |
| 118 | + |
| 119 | +Contributions are welcome! |
| 120 | + |
| 121 | +- [Development Workflow](CONTRIBUTING.md#development-workflow) |
| 122 | +- [Sending a Pull Request](CONTRIBUTING.md#sending-a-pull-request) |
| 123 | +- [Code of Conduct](CODE_OF_CONDUCT.md) |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## 🪪 License |
| 128 | + |
| 129 | +MIT © [**Gautham Vijayan**](https://gauthamvijay.com) |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +Made with ❤️ and [**Nitro Modules**](https://nitro.margelo.com) |
0 commit comments