Skip to content

Commit 5d9bc5f

Browse files
authored
fix(lib-storage): fix fs error on browsers when using lib-storage upload (#2165)
1 parent 19f978c commit 5d9bc5f

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

Diff for: lib/lib-storage/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
},
5252
"browser": {
5353
"stream": "stream-browserify",
54-
"fs": "./src/runtimeConfig.browser",
5554
"./runtimeConfig": "./src/runtimeConfig.browser"
5655
},
5756
"react-native": {

Diff for: lib/lib-storage/src/bytelength.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { lstatSync } from "fs";
1+
import { ClientDefaultValues } from "./runtimeConfig";
22

33
export const byteLength = (input: any) => {
44
if (input === null || input === undefined) return 0;
@@ -11,7 +11,7 @@ export const byteLength = (input: any) => {
1111
return input.size;
1212
} else if (typeof input.path === "string") {
1313
try {
14-
return lstatSync(input.path).size;
14+
return ClientDefaultValues.lstatSync(input.path).size;
1515
} catch (error) {
1616
return undefined;
1717
}

Diff for: lib/lib-storage/src/runtimeConfig.shared.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
22
* @internal
33
*/
4-
export const ClientSharedValues = {};
4+
export const ClientSharedValues = {
5+
lstatSync: () => {},
6+
};

Diff for: lib/lib-storage/src/runtimeConfig.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { ClientSharedValues } from "./runtimeConfig.shared";
2+
import { lstatSync } from "fs";
23

34
/**
45
* @internal
56
*/
67
export const ClientDefaultValues = {
78
...ClientSharedValues,
89
runtime: "node",
10+
lstatSync,
911
};

0 commit comments

Comments
 (0)