Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nwaughachukwuma/upload-chunks
Code examples for chunk uploads to different storage providers.
https://github.com/nwaughachukwuma/upload-chunks
Last synced: about 1 month ago
JSON representation
Code examples for chunk uploads to different storage providers.
- Host: GitHub
- URL: https://github.com/nwaughachukwuma/upload-chunks
- Owner: nwaughachukwuma
- License: mit
- Created: 2022-02-12T01:18:21.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-27T09:41:09.000Z (almost 3 years ago)
- Last Synced: 2023-03-02T13:40:51.835Z (almost 2 years ago)
- Language: TypeScript
- Size: 54.7 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Upload-Chunks
Code examples for chunk uploads to different storage providers.
1. Cloudinary Chunk Uploads
```ts
import upchunk from "./lib/uploadChunks";const CLOUDINARY_UPLOAD_URL =
"https://api.cloudinary.com/v1_1/cpnwaugha/auto/upload";const onchangeInput = async (e) => {
const file: File = e.target.files[0];
await upchunk(file, {
url: CLOUDINARY_UPLOAD_URL,
appendToFormData: {
upload_preset: "rtdfil2g",
cloud_name: "cpnwaugha",
tags: ["t1", "t2"],
public_id: `chunk_uploads-${Date.now()}`,
},
headers: {},
});
};picker = document.getElementById("file_picker");
picker.addEventListener("onchange", (e) => {
e.preventDefault();
onchangeInput(e)
});
```2. Mux Chunk Uploads
May not be used to upload to Cloudinary.
> See https://github.com/muxinc/upchunk
```ts
import muxUpchunk from './muxUpChunk'picker = document.getElementById("file_picker");
picker.addEventListener("onchange", async (e) => {
e.preventDefault();
const file = e.target.files[0];
const chunkSize = 1024 * 1024 * 5; // 5MB
const endpoint = 'your-endpoint';await muxUpchunk({file, endpoint, chunkSize})
});
```