@quatrain/storage-supabase 1.2.11-beta.0 → 1.2.12-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -96,11 +96,13 @@ export declare class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
96
96
|
*/
|
|
97
97
|
getReadable(file: FileType): Promise<Readable>;
|
|
98
98
|
/**
|
|
99
|
-
* Fetches and
|
|
99
|
+
* Fetches and streams the file content into the given response stream or HTTP response object.
|
|
100
|
+
* Piped directly if `res` is a Writable stream (implements `.on()`), or dispatches via `.send()` / `.write()`
|
|
101
|
+
* as a defensive fallback for non-stream response objects.
|
|
100
102
|
*
|
|
101
|
-
* @param file - File to stream.
|
|
102
|
-
* @param res - Writable stream or HTTP response object.
|
|
103
|
-
* @returns The piped stream instance.
|
|
103
|
+
* @param file - File footprint to stream.
|
|
104
|
+
* @param res - Writable stream or HTTP response object (supports .pipe(), .send(), or .write()/.end()).
|
|
105
|
+
* @returns The piped stream instance or response completion.
|
|
104
106
|
*/
|
|
105
107
|
stream(file: FileType, res: any): Promise<any>;
|
|
106
108
|
/**
|
|
@@ -275,11 +275,13 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
277
|
/**
|
|
278
|
-
* Fetches and
|
|
278
|
+
* Fetches and streams the file content into the given response stream or HTTP response object.
|
|
279
|
+
* Piped directly if `res` is a Writable stream (implements `.on()`), or dispatches via `.send()` / `.write()`
|
|
280
|
+
* as a defensive fallback for non-stream response objects.
|
|
279
281
|
*
|
|
280
|
-
* @param file - File to stream.
|
|
281
|
-
* @param res - Writable stream or HTTP response object.
|
|
282
|
-
* @returns The piped stream instance.
|
|
282
|
+
* @param file - File footprint to stream.
|
|
283
|
+
* @param res - Writable stream or HTTP response object (supports .pipe(), .send(), or .write()/.end()).
|
|
284
|
+
* @returns The piped stream instance or response completion.
|
|
283
285
|
*/
|
|
284
286
|
stream(file, res) {
|
|
285
287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -291,7 +293,16 @@ class SupabaseStorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
291
293
|
const readable = new node_stream_1.Readable();
|
|
292
294
|
readable.push(buffer);
|
|
293
295
|
readable.push(null);
|
|
294
|
-
|
|
296
|
+
if (typeof (res === null || res === void 0 ? void 0 : res.on) === 'function') {
|
|
297
|
+
return readable.pipe(res);
|
|
298
|
+
}
|
|
299
|
+
else if (typeof (res === null || res === void 0 ? void 0 : res.send) === 'function') {
|
|
300
|
+
return res.send(buffer);
|
|
301
|
+
}
|
|
302
|
+
else if (typeof (res === null || res === void 0 ? void 0 : res.write) === 'function' && typeof (res === null || res === void 0 ? void 0 : res.end) === 'function') {
|
|
303
|
+
res.write(buffer);
|
|
304
|
+
return res.end();
|
|
305
|
+
}
|
|
295
306
|
});
|
|
296
307
|
}
|
|
297
308
|
/**
|
package/package.json
CHANGED
|
@@ -289,11 +289,13 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
|
-
* Fetches and
|
|
292
|
+
* Fetches and streams the file content into the given response stream or HTTP response object.
|
|
293
|
+
* Piped directly if `res` is a Writable stream (implements `.on()`), or dispatches via `.send()` / `.write()`
|
|
294
|
+
* as a defensive fallback for non-stream response objects.
|
|
293
295
|
*
|
|
294
|
-
* @param file - File to stream.
|
|
295
|
-
* @param res - Writable stream or HTTP response object.
|
|
296
|
-
* @returns The piped stream instance.
|
|
296
|
+
* @param file - File footprint to stream.
|
|
297
|
+
* @param res - Writable stream or HTTP response object (supports .pipe(), .send(), or .write()/.end()).
|
|
298
|
+
* @returns The piped stream instance or response completion.
|
|
297
299
|
*/
|
|
298
300
|
async stream(file: FileType, res: any) {
|
|
299
301
|
Storage.debug(`GET Stream : ${file.ref}`)
|
|
@@ -306,7 +308,14 @@ export class SupabaseStorageAdapter extends AbstractStorageAdapter {
|
|
|
306
308
|
readable.push(buffer)
|
|
307
309
|
readable.push(null)
|
|
308
310
|
|
|
309
|
-
|
|
311
|
+
if (typeof res?.on === 'function') {
|
|
312
|
+
return readable.pipe(res)
|
|
313
|
+
} else if (typeof res?.send === 'function') {
|
|
314
|
+
return res.send(buffer)
|
|
315
|
+
} else if (typeof res?.write === 'function' && typeof res?.end === 'function') {
|
|
316
|
+
res.write(buffer)
|
|
317
|
+
return res.end()
|
|
318
|
+
}
|
|
310
319
|
}
|
|
311
320
|
|
|
312
321
|
/**
|