Skip to content

Commit bf8fafe

Browse files
authored
Merge pull request #391 from autonomys/fix-stream-handling
fix: stream handling
2 parents 0612ae8 + 8d289a2 commit bf8fafe

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/utility/file-caching/src/models.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Keyv } from 'keyv'
2-
import { Stream } from 'stream'
2+
import { Readable } from 'stream'
33

44
export type FileResponse = {
5-
data: Stream
5+
data: Readable
66
mimeType?: string
77
filename?: string
88
size?: bigint
@@ -16,7 +16,7 @@ export interface BaseCacheConfig {
1616
}
1717

1818
export interface FileCache {
19-
get: (cid: string) => Promise<Buffer | Stream | null>
20-
set: (cid: string, data: Buffer | Stream) => Promise<void>
19+
get: (cid: string) => Promise<Buffer | Readable | null>
20+
set: (cid: string, data: Buffer | Readable) => Promise<void>
2121
remove: (cid: string) => Promise<void>
2222
}

packages/utility/file-caching/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import fs from 'fs'
22
import fsPromises from 'fs/promises'
33
import path from 'path'
4-
import { Stream } from 'stream'
4+
import { Readable } from 'stream'
55
import { v4 } from 'uuid'
66

77
export const writeFile = async (
88
filepath: string,
9-
data: Stream,
9+
data: Readable,
1010
ensureDirectoryExistance: boolean = true,
1111
) => {
1212
const tempFilePath = path.join(path.dirname(filepath), `${v4()}.tmp`)

0 commit comments

Comments
 (0)