@@ -11,8 +11,10 @@ import {
1111 WatchStopParams ,
1212} from './watch' ;
1313import { APIPromise } from '../../../core/api-promise' ;
14+ import { type Uploadable } from '../../../core/uploads' ;
1415import { buildHeaders } from '../../../internal/headers' ;
1516import { RequestOptions } from '../../../internal/request-options' ;
17+ import { multipartFormRequestOptions } from '../../../internal/uploads' ;
1618import { path } from '../../../internal/utils/path' ;
1719
1820export class Fs extends APIResource {
@@ -70,6 +72,29 @@ export class Fs extends APIResource {
7072 } ) ;
7173 }
7274
75+ /**
76+ * Returns a ZIP file containing the contents of the specified directory.
77+ *
78+ * @example
79+ * ```ts
80+ * const response = await client.browsers.fs.downloadDirZip(
81+ * 'id',
82+ * { path: '/J!' },
83+ * );
84+ *
85+ * const content = await response.blob();
86+ * console.log(content);
87+ * ```
88+ */
89+ downloadDirZip ( id : string , query : FDownloadDirZipParams , options ?: RequestOptions ) : APIPromise < Response > {
90+ return this . _client . get ( path `/browsers/${ id } /fs/download_dir_zip` , {
91+ query,
92+ ...options ,
93+ headers : buildHeaders ( [ { Accept : 'application/zip' } , options ?. headers ] ) ,
94+ __binaryResponse : true ,
95+ } ) ;
96+ }
97+
7398 /**
7499 * Get information about a file or directory
75100 *
@@ -162,6 +187,52 @@ export class Fs extends APIResource {
162187 } ) ;
163188 }
164189
190+ /**
191+ * Allows uploading single or multiple files to the remote filesystem.
192+ *
193+ * @example
194+ * ```ts
195+ * await client.browsers.fs.upload('id', {
196+ * files: [
197+ * {
198+ * dest_path: '/J!',
199+ * file: fs.createReadStream('path/to/file'),
200+ * },
201+ * ],
202+ * });
203+ * ```
204+ */
205+ upload ( id : string , body : FUploadParams , options ?: RequestOptions ) : APIPromise < void > {
206+ return this . _client . post (
207+ path `/browsers/${ id } /fs/upload` ,
208+ multipartFormRequestOptions (
209+ { body, ...options , headers : buildHeaders ( [ { Accept : '*/*' } , options ?. headers ] ) } ,
210+ this . _client ,
211+ ) ,
212+ ) ;
213+ }
214+
215+ /**
216+ * Upload a zip file and extract its contents to the specified destination path.
217+ *
218+ * @example
219+ * ```ts
220+ * await client.browsers.fs.uploadZip('id', {
221+ * dest_path: '/J!',
222+ * zip_file: fs.createReadStream('path/to/file'),
223+ * });
224+ * ```
225+ */
226+ uploadZip ( id : string , body : FUploadZipParams , options ?: RequestOptions ) : APIPromise < void > {
227+ return this . _client . post (
228+ path `/browsers/${ id } /fs/upload_zip` ,
229+ multipartFormRequestOptions (
230+ { body, ...options , headers : buildHeaders ( [ { Accept : '*/*' } , options ?. headers ] ) } ,
231+ this . _client ,
232+ ) ,
233+ ) ;
234+ }
235+
165236 /**
166237 * Write or create a file
167238 *
@@ -290,6 +361,13 @@ export interface FDeleteFileParams {
290361 path : string ;
291362}
292363
364+ export interface FDownloadDirZipParams {
365+ /**
366+ * Absolute directory path to archive and download.
367+ */
368+ path : string ;
369+ }
370+
293371export interface FFileInfoParams {
294372 /**
295373 * Absolute path of the file or directory.
@@ -345,6 +423,30 @@ export interface FSetFilePermissionsParams {
345423 owner ?: string ;
346424}
347425
426+ export interface FUploadParams {
427+ files : Array < FUploadParams . File > ;
428+ }
429+
430+ export namespace FUploadParams {
431+ export interface File {
432+ /**
433+ * Absolute destination path to write the file.
434+ */
435+ dest_path : string ;
436+
437+ file : Uploadable ;
438+ }
439+ }
440+
441+ export interface FUploadZipParams {
442+ /**
443+ * Absolute destination directory to extract the archive to.
444+ */
445+ dest_path : string ;
446+
447+ zip_file : Uploadable ;
448+ }
449+
348450export interface FWriteFileParams {
349451 /**
350452 * Query param: Destination absolute file path.
@@ -366,11 +468,14 @@ export declare namespace Fs {
366468 type FCreateDirectoryParams as FCreateDirectoryParams ,
367469 type FDeleteDirectoryParams as FDeleteDirectoryParams ,
368470 type FDeleteFileParams as FDeleteFileParams ,
471+ type FDownloadDirZipParams as FDownloadDirZipParams ,
369472 type FFileInfoParams as FFileInfoParams ,
370473 type FListFilesParams as FListFilesParams ,
371474 type FMoveParams as FMoveParams ,
372475 type FReadFileParams as FReadFileParams ,
373476 type FSetFilePermissionsParams as FSetFilePermissionsParams ,
477+ type FUploadParams as FUploadParams ,
478+ type FUploadZipParams as FUploadZipParams ,
374479 type FWriteFileParams as FWriteFileParams ,
375480 } ;
376481
0 commit comments