Skip to content

Commit 10f1e76

Browse files
chore(lib-storage): use consistent imports (#2101)
Fixes #2100
1 parent e352a13 commit 10f1e76

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

lib/lib-storage/example-code/file-upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import * as fs from "fs";
12
import { Upload } from "@aws-sdk/lib-storage";
23
import { S3 } from "@aws-sdk/client-s3";
34
import { configuration } from "./config";
45

5-
const fs = require("fs");
66
const fileStream = fs.createReadStream(__dirname + "/big.file");
77

88
(async () => {

lib/lib-storage/src/bytelength.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { lstatSync } from "fs";
2+
13
export const byteLength = (input: any) => {
24
if (input === null || input === undefined) return 0;
35
if (typeof input === "string") input = Buffer.from(input);
@@ -9,7 +11,7 @@ export const byteLength = (input: any) => {
911
return input.size;
1012
} else if (typeof input.path === "string") {
1113
try {
12-
return require("fs").lstatSync(input.path).size;
14+
return lstatSync(input.path).size;
1315
} catch (error) {
1416
return undefined;
1517
}

lib/lib-storage/src/chunker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stream from "stream";
1+
import { Readable } from "stream";
22
import { Buffer } from "buffer";
33

44
import { BodyDataTypes } from "./types";
@@ -10,8 +10,8 @@ import { getDataReadable } from "./chunks/getDataReadable";
1010
export const getChunk = (data: BodyDataTypes, partSize: number) => {
1111
if (data instanceof Buffer) {
1212
return getChunkBuffer(data, partSize);
13-
} else if (data instanceof stream.Readable) {
14-
return getChunkStream<stream.Readable>(data, partSize, getDataReadable);
13+
} else if (data instanceof Readable) {
14+
return getChunkStream<Readable>(data, partSize, getDataReadable);
1515
} else if (data instanceof String || typeof data === "string" || data instanceof Uint8Array) {
1616
// chunk Strings, Uint8Array.
1717
return getChunkBuffer(Buffer.from(data), partSize);

lib/lib-storage/src/chunks/getDataReadable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Stream from "stream";
1+
import { Readable } from "stream";
22
import { Buffer } from "buffer";
33

4-
export async function* getDataReadable(data: Stream.Readable): AsyncGenerator<Buffer> {
4+
export async function* getDataReadable(data: Readable): AsyncGenerator<Buffer> {
55
for await (const chunk of data) {
66
yield Buffer.from(chunk);
77
}

0 commit comments

Comments
 (0)