Skip to content

Commit 90afd9e

Browse files
authored
reject images larger than 128GiB (#227)
reject images larger than 128GiB
1 parent ddf3d15 commit 90afd9e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/lib/nodes/image/upload.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import retry from "async-retry";
88
import ora, { type Ora } from "ora";
99
import cliSpinners from "npm:cli-spinners";
1010
import { apiClient } from "../../../apiClient.ts";
11+
import { logAndQuit } from "../../../helpers/errors.ts";
1112

1213
async function readChunk(
1314
filePath: string,
@@ -94,6 +95,16 @@ const upload = new Command("upload")
9495
const fileInfo = await Deno.stat(filePath);
9596
const fileSize = fileInfo.size;
9697

98+
// Check file size limit (128 GiB)
99+
const maxFileSize = 128 * 1024 * 1024 * 1024; // 128 GiB in bytes
100+
if (fileSize > maxFileSize) {
101+
logAndQuit(
102+
`File size exceeds maximum allowed size of 128 GiB. File size: ${
103+
(fileSize / (1024 * 1024 * 1024)).toFixed(2)
104+
} GiB`,
105+
);
106+
}
107+
97108
// Calculate parts for progress tracking
98109
const minChunk = 5 * 1024 * 1024; // 5 MiB (minimum)
99110
const defaultChunk = 64 * 1024 * 1024; // 64 MiB

0 commit comments

Comments
 (0)