Skip to content

Commit dc5e27d

Browse files
committed
feat: update uploadFile method to accept Buffer in addition to Readable stream and add new types for upload tasks and multipart options
1 parent e6e046d commit dc5e27d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/services/network/upload.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { UploadOptions } from '../../types/network.types';
55
export class UploadService {
66
public static readonly instance: UploadService = new UploadService();
77

8-
async uploadFile(url: string, from: Readable, options: UploadOptions): Promise<{ etag: string }> {
8+
async uploadFile(url: string, from: Readable | Buffer, options: UploadOptions): Promise<{ etag: string }> {
99
const response = await axios.put(url, from, {
1010
signal: options.abortController?.signal,
1111
onUploadProgress: (progressEvent) => {

src/types/network.types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ export interface SelfsignedCert {
1717
cert: string | Buffer;
1818
key: string | Buffer;
1919
}
20+
21+
export interface UploadTask {
22+
contentToUpload: Buffer;
23+
urlToUpload: string;
24+
index: number;
25+
}
26+
27+
export interface UploadMultipartOptions extends UploadOptions {
28+
parts: number;
29+
}

0 commit comments

Comments
 (0)