diff --git a/sdk/storage/storage-blob/src/utils/utils.node.ts b/sdk/storage/storage-blob/src/utils/utils.node.ts index 98f2b3a78c61..2ca67292ab65 100644 --- a/sdk/storage/storage-blob/src/utils/utils.node.ts +++ b/sdk/storage/storage-blob/src/utils/utils.node.ts @@ -18,7 +18,7 @@ export async function streamToBuffer( buffer: Buffer, offset: number, end: number, - encoding?: string + encoding?: BufferEncoding ): Promise { let pos = 0; // Position in stream const count = end - offset; // Total amount of data needed in stream @@ -72,7 +72,7 @@ export async function streamToBuffer( export async function streamToBuffer2( stream: NodeJS.ReadableStream, buffer: Buffer, - encoding?: string + encoding?: BufferEncoding ): Promise { let pos = 0; // Position in stream const bufferSize = buffer.length; @@ -113,7 +113,7 @@ export async function streamToBuffer2( */ export async function streamToBuffer3( readableStream: NodeJS.ReadableStream, - encoding?: string + encoding?: BufferEncoding ): Promise { return new Promise((resolve, reject) => { const chunks: Buffer[] = []; diff --git a/sdk/storage/storage-common/src/BufferScheduler.ts b/sdk/storage/storage-common/src/BufferScheduler.ts index 6435aba9059e..b6554a8a7772 100644 --- a/sdk/storage/storage-common/src/BufferScheduler.ts +++ b/sdk/storage/storage-common/src/BufferScheduler.ts @@ -92,7 +92,7 @@ export class BufferScheduler { /** * Encoding of the input Readable stream which has string data type instead of Buffer. */ - private encoding?: string; + private encoding?: BufferEncoding; /** * How many buffers have been allocated. @@ -141,7 +141,7 @@ export class BufferScheduler { maxBuffers: number, outgoingHandler: OutgoingHandler, concurrency: number, - encoding?: string + encoding?: BufferEncoding ) { if (bufferSize <= 0) { throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`); diff --git a/sdk/storage/storage-file-datalake/src/utils/BufferScheduler.ts b/sdk/storage/storage-file-datalake/src/utils/BufferScheduler.ts index c3a03a6c80a0..0280098cfb66 100644 --- a/sdk/storage/storage-file-datalake/src/utils/BufferScheduler.ts +++ b/sdk/storage/storage-file-datalake/src/utils/BufferScheduler.ts @@ -87,7 +87,7 @@ export class BufferScheduler { /** * Encoding of the input Readable stream which has string data type instead of Buffer. */ - private encoding?: string; + private encoding?: BufferEncoding; /** * How many buffers have been allocated. @@ -136,7 +136,7 @@ export class BufferScheduler { maxBuffers: number, outgoingHandler: OutgoingHandler, concurrency: number, - encoding?: string + encoding?: BufferEncoding ) { if (bufferSize <= 0) { throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`); diff --git a/sdk/storage/storage-file-datalake/src/utils/utils.node.ts b/sdk/storage/storage-file-datalake/src/utils/utils.node.ts index 7b56941c75bb..931104e82a74 100644 --- a/sdk/storage/storage-file-datalake/src/utils/utils.node.ts +++ b/sdk/storage/storage-file-datalake/src/utils/utils.node.ts @@ -3,7 +3,6 @@ import * as fs from "fs"; import * as util from "util"; -import { isNode } from "@azure/core-http"; /** * Reads a readable stream into buffer. Fill the buffer from offset to end. @@ -19,7 +18,7 @@ export async function streamToBuffer( buffer: Buffer, offset: number, end: number, - encoding?: string + encoding?: BufferEncoding ): Promise { let pos = 0; // Position in stream const count = end - offset; // Total amount of data needed in stream @@ -73,7 +72,7 @@ export async function streamToBuffer( export async function streamToBuffer2( stream: NodeJS.ReadableStream, buffer: Buffer, - encoding?: string + encoding?: BufferEncoding ): Promise { let pos = 0; // Position in stream const bufferSize = buffer.length; @@ -110,6 +109,6 @@ export async function streamToBuffer2( * * Promisified version of fs.stat(). */ -export const fsStat = util.promisify(isNode ? fs.stat : function stat() {}); +export const fsStat = util.promisify(fs.stat); export const fsCreateReadStream = fs.createReadStream; diff --git a/sdk/storage/storage-file-share/src/utils/BufferScheduler.ts b/sdk/storage/storage-file-share/src/utils/BufferScheduler.ts index f5131d0dfb33..56988ccb5fd9 100644 --- a/sdk/storage/storage-file-share/src/utils/BufferScheduler.ts +++ b/sdk/storage/storage-file-share/src/utils/BufferScheduler.ts @@ -87,7 +87,7 @@ export class BufferScheduler { /** * Encoding of the input Readable stream which has string data type instead of Buffer. */ - private encoding?: string; + private encoding?: BufferEncoding; /** * How many buffers have been allocated. @@ -136,7 +136,7 @@ export class BufferScheduler { maxBuffers: number, outgoingHandler: OutgoingHandler, concurrency: number, - encoding?: string + encoding?: BufferEncoding ) { if (bufferSize <= 0) { throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`); diff --git a/sdk/storage/storage-file-share/src/utils/utils.node.ts b/sdk/storage/storage-file-share/src/utils/utils.node.ts index b773afe82221..547cca0fbcc4 100644 --- a/sdk/storage/storage-file-share/src/utils/utils.node.ts +++ b/sdk/storage/storage-file-share/src/utils/utils.node.ts @@ -18,7 +18,7 @@ export async function streamToBuffer( buffer: Buffer, offset: number, end: number, - encoding?: string + encoding?: BufferEncoding ): Promise { let pos = 0; // Position in stream const count = end - offset; // Total amount of data needed in stream