Skip to content

Commit 4c85fe9

Browse files
During Pages and R2 validations, show sizes in MiB (consistently with the Cloudflare docs) (#4577)
1 parent 2b63e20 commit 4c85fe9

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

.changeset/eight-stingrays-tap.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
During the R2 validation, show `MAX_UPLOAD_SIZE` errors using MiB (consistently with the Cloudflare docs)

.changeset/itchy-knives-share.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
During the Pages validation, show `MAX_UPLOAD_SIZE` errors using MiB (consistently with the Cloudflare docs)

packages/wrangler/src/__tests__/pages/project-validate.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ describe("project validate", () => {
3535

3636
await expect(() => runWrangler("pages project validate .")).rejects
3737
.toThrowErrorMatchingInlineSnapshot(`
38-
"Error: Pages only supports files up to 1.05 MB in size
39-
logo.png is 1.05 MB in size"
38+
"Error: Pages only supports files up to 1 MiB in size
39+
logo.png is 1 MiB in size"
4040
`);
4141
});
4242

packages/wrangler/src/__tests__/r2.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ describe("r2", () => {
316316
)
317317
).rejects.toThrowErrorMatchingInlineSnapshot(`
318318
"Error: Wrangler only supports uploading files up to ${prettyBytes(
319-
MAX_UPLOAD_SIZE
319+
MAX_UPLOAD_SIZE,
320+
{ binary: true }
320321
)} in size
321-
wormhole-img.png is ${prettyBytes(TOO_BIG_FILE_SIZE)} in size"
322+
wormhole-img.png is ${prettyBytes(TOO_BIG_FILE_SIZE, { binary: true })} in size"
322323
`);
323324
});
324325

packages/wrangler/src/pages/validate.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ export const validate = async (args: {
9494
if (filestat.size > MAX_ASSET_SIZE) {
9595
throw new FatalError(
9696
`Error: Pages only supports files up to ${prettyBytes(
97-
MAX_ASSET_SIZE
98-
)} in size\n${name} is ${prettyBytes(filestat.size)} in size`,
97+
MAX_ASSET_SIZE,
98+
{ binary: true }
99+
)} in size\n${name} is ${prettyBytes(filestat.size, {
100+
binary: true,
101+
})} in size`,
99102
1
100103
);
101104
}

packages/wrangler/src/r2/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,11 @@ export function r2(r2Yargs: CommonYargsArgv) {
262262
if (objectSize > MAX_UPLOAD_SIZE) {
263263
throw new FatalError(
264264
`Error: Wrangler only supports uploading files up to ${prettyBytes(
265-
MAX_UPLOAD_SIZE
266-
)} in size\n${key} is ${prettyBytes(objectSize)} in size`,
265+
MAX_UPLOAD_SIZE,
266+
{ binary: true }
267+
)} in size\n${key} is ${prettyBytes(objectSize, {
268+
binary: true,
269+
})} in size`,
267270
1
268271
);
269272
}

0 commit comments

Comments
 (0)