From b2fd723e5df98432faa66fec3c9e7695d0942755 Mon Sep 17 00:00:00 2001 From: Balint Ujvari Date: Mon, 13 Jul 2026 14:44:46 +0200 Subject: [PATCH 1/2] feat: streaming uploadData for node and browser envs --- src/bee.ts | 2 +- src/modules/bytes.ts | 3 ++- src/utils/type.ts | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bee.ts b/src/bee.ts index 68aeeb7c..221ef6fb 100644 --- a/src/bee.ts +++ b/src/bee.ts @@ -227,7 +227,7 @@ export class Bee { */ async uploadData( postageBatchId: BatchId | Uint8Array | string, - data: string | Uint8Array, + data: string | Uint8Array | Blob | Readable, options?: RedundantUploadOptions, requestOptions?: BeeRequestOptions, ): Promise { diff --git a/src/modules/bytes.ts b/src/modules/bytes.ts index ce3fd8fe..6c0853c8 100644 --- a/src/modules/bytes.ts +++ b/src/modules/bytes.ts @@ -1,4 +1,5 @@ import { Optional } from 'cafe-utility' +import { Readable } from 'stream' import type { BeeRequestOptions, DownloadOptions, RedundantUploadOptions, ReferenceInformation } from '../types' import { UploadResult } from '../types' import { UploadResultBody } from '../types/schema/upload' @@ -22,7 +23,7 @@ const endpoint = 'bytes' */ export async function upload( requestOptions: BeeRequestOptions, - data: string | Uint8Array, + data: string | Uint8Array | Blob | Readable, postageBatchId: BatchId, options?: RedundantUploadOptions, ): Promise { diff --git a/src/utils/type.ts b/src/utils/type.ts index b21888fe..7949f940 100644 --- a/src/utils/type.ts +++ b/src/utils/type.ts @@ -36,9 +36,9 @@ export function isTag(value: unknown): value is Tag { * @param value * @throws TypeError if not valid */ -export function assertData(value: unknown): asserts value is string | Uint8Array { - if (typeof value !== 'string' && !(value instanceof Uint8Array)) { - throw new TypeError('Data must be either string or Uint8Array!') +export function assertData(value: unknown): asserts value is string | Uint8Array | Blob | stream.Readable { + if (typeof value !== 'string' && !(value instanceof Uint8Array) && !(value instanceof Blob) && !isReadable(value)) { + throw new TypeError('Data must be either string, Uint8Array, Blob or Readable!') } } From 5a7130d24ccc81e08bb11a1120f7ec140a35ed0b Mon Sep 17 00:00:00 2001 From: Balint Ujvari Date: Mon, 20 Jul 2026 02:08:58 +0200 Subject: [PATCH 2/2] fix: http reattach request body data --- src/utils/http.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/http.ts b/src/utils/http.ts index 9ab5a631..94d3be2d 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -39,7 +39,13 @@ export interface BeeRequestConfig extends RequestInit { * @param config Internal settings and/or Bee settings */ export async function http(options: BeeRequestOptions, config: BeeRequestConfig): Promise> { - const requestConfig: BeeRequestConfig = Objects.deepMerge3(DEFAULT_HTTP_CONFIG, config, options) + const rawData = config.data + const requestConfig: BeeRequestConfig = Objects.deepMerge3( + DEFAULT_HTTP_CONFIG, + { ...config, data: undefined }, + options, + ) + requestConfig.data = rawData if (options.signal) { requestConfig.signal = options.signal