diff --git a/src/client.ts b/src/client.ts index c3bab9f..f800468 100644 --- a/src/client.ts +++ b/src/client.ts @@ -288,23 +288,19 @@ export class Client { ); } - async uploadFile(stream: Blob, size?: bigint): Promise; + async uploadFile(stream: Blob, size?: bigint): Promise; async uploadFile( stream: ReadableStream, hashStream: ReadableStream, size: bigint, - ): Promise; - async uploadFile(stream: Uint8Array, size?: bigint): Promise; + ): Promise; + async uploadFile(stream: Uint8Array, size?: bigint): Promise; async uploadFile( stream: NodeJS.ReadableStream, hashStream: NodeJS.ReadableStream, size?: bigint, - ): Promise; - async uploadFile( - stream: any, - hashStream?: any, - size?: bigint, - ): Promise { + ): Promise; + async uploadFile(stream: any, hashStream?: any, size?: bigint): Promise { const Blob = await this.getBlobObject(); if (stream instanceof Uint8Array || stream instanceof Blob) { @@ -324,14 +320,14 @@ export class Client { return this.uploadFileTus(stream, hashStream, size); } - private async uploadFileSmall(stream: Blob): Promise; + private async uploadFileSmall(stream: Blob): Promise; private async uploadFileSmall( stream: ReadableStream, hashStream: ReadableStream, - ): Promise; - private async uploadFileSmall(stream: Uint8Array): Promise; - private async uploadFileSmall(stream: NodeJS.ReadableStream): Promise; - private async uploadFileSmall(stream: any): Promise { + ): Promise; + private async uploadFileSmall(stream: Uint8Array): Promise; + private async uploadFileSmall(stream: NodeJS.ReadableStream): Promise; + private async uploadFileSmall(stream: any): Promise { const Blob = await this.getBlobObject(); if (stream instanceof ReadableStream) { @@ -373,29 +369,26 @@ export class Client { { auth: true }, ); - return response.cid; + return CID.decode(response.cid); } - private async uploadFileTus(stream: Blob, size?: bigint): Promise; + private async uploadFileTus(stream: Blob, size?: bigint): Promise; private async uploadFileTus( stream: ReadableStream, hashStream: ReadableStream, size?: bigint, - ): Promise; - private async uploadFileTus( - stream: Uint8Array, - size?: bigint, - ): Promise; + ): Promise; + private async uploadFileTus(stream: Uint8Array, size?: bigint): Promise; private async uploadFileTus( stream: NodeJS.ReadableStream, hashStream: ReadableStream, size?: bigint, - ): Promise; + ): Promise; private async uploadFileTus( stream: any, hashStream?: any, size?: bigint, - ): Promise { + ): Promise { if (["bigint", "number"].includes(typeof hashStream)) { size = BigInt(hashStream); hashStream = undefined; @@ -483,7 +476,7 @@ export class Client { }); } - return cid.toString(); + return cid; } async getUploadStatus(cid: string) {