File tree Expand file tree Collapse file tree 4 files changed +9
-7
lines changed
Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1+ import * as fs from "fs" ;
12import { Upload } from "@aws-sdk/lib-storage" ;
23import { S3 } from "@aws-sdk/client-s3" ;
34import { configuration } from "./config" ;
45
5- const fs = require ( "fs" ) ;
66const fileStream = fs . createReadStream ( __dirname + "/big.file" ) ;
77
88( async ( ) => {
Original file line number Diff line number Diff line change 1+ import { lstatSync } from "fs" ;
2+
13export 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 }
Original file line number Diff line number Diff line change 1- import stream from "stream" ;
1+ import { Readable } from "stream" ;
22import { Buffer } from "buffer" ;
33
44import { BodyDataTypes } from "./types" ;
@@ -10,8 +10,8 @@ import { getDataReadable } from "./chunks/getDataReadable";
1010export 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 ) ;
Original file line number Diff line number Diff line change 1- import Stream from "stream" ;
1+ import { Readable } from "stream" ;
22import { 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 }
You can’t perform that action at this time.
0 commit comments