Skip to content

Commit ff24227

Browse files
committed
feat: add new createWriteStream method to the storage adapter interface
AdminForth/1796/image
1 parent 38c88f6 commit ff24227

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

adminforth/types/adapters/StorageAdapter.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ export interface StorageAdapter {
8282
* @returns A promise that returns true if the URL belongs to this adapter, false otherwise.
8383
*/
8484
isInternalUrl (url: string): Promise<boolean>;
85+
86+
/**
87+
* Creates an object writer for the specified key and content type.
88+
* For example, this can be used to write large files in chunks or streams (AWS S3 Multipart Upload).
89+
* @param key - The key of the file to be written e.g. "uploads/file.txt"
90+
* @param contentType - The MIME type of the file to be written e.g. "image/png"
91+
*/
92+
createWriteStream(key: string, contentType: string): Promise<ObjectWriter>;
8593
}
8694

87-
95+
interface ObjectWriter {
96+
write(data: string | Buffer | Uint8Array): Promise<void>;
97+
close(): Promise<void>;
98+
abort(): Promise<void>;
99+
}

0 commit comments

Comments
 (0)