mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
fix(upload): fail fast on 0-byte files in multipartUpload
A 0-byte file produced a multipart upload with zero parts, which S3/R2 reject with a cryptic CompleteMultipartUpload error. Guard file.size === 0 up front with a clear message, before any S3 request is issued. Cloudflare-upload #4. Test: tests/multipart-empty-file-guard.test.mjs. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
6b603cc21c
commit
04ae0ec4e6
2 files changed
+43
No files matched your search
@@ -177,6 +177,11 @@ export async function multipartUpload({
|
||||
if (!file) {
|
||||
throw new Error("File is required");
|
||||
}
|
||||
// A 0-byte file produces a multipart upload with zero parts, which S3/R2
|
||||
// rejects with a cryptic CompleteMultipartUpload error. Fail fast and clearly.
|
||||
if (typeof file.size === "number" && file.size === 0) {
|
||||
throw new Error("File is empty (0 bytes). Choose a non-empty file to upload.");
|
||||
}
|
||||
|
||||
const {
|
||||
CreateMultipartUploadCommand,
|
||||
|
||||
Reference in new issue
Block a user