mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
The commit refactors the chunked upload system to support a transformation pipeline. Key changes include: - Replace SSE field names for consistency (sseChannelId, sseUrl) - Fix progress reporting structure with state and percent fields - Add transformation handlers (a-dash, mq-hls, img-compress, video-compress) - Create new Upload class with clear separation of concerns - Improve file processing workflow with better directory structure - Fix typo in UploadButton component (progess → progress) - Remove deprecated file processing services
23 lines
507 B
JavaScript
23 lines
507 B
JavaScript
// Original fork from https://github.com/sindresorhus/read-chunk
|
|
import { open } from "node:fs/promises"
|
|
|
|
export default async (filePath, { length, startPosition }) => {
|
|
const fileDescriptor = await open(filePath, "r")
|
|
|
|
try {
|
|
let { bytesRead, buffer } = await fileDescriptor.read({
|
|
buffer: new Uint8Array(length),
|
|
length,
|
|
position: startPosition,
|
|
})
|
|
|
|
if (bytesRead < length) {
|
|
buffer = buffer.subarray(0, bytesRead)
|
|
}
|
|
|
|
return buffer
|
|
} finally {
|
|
await fileDescriptor?.close()
|
|
}
|
|
}
|