@@ -82,6 +82,19 @@ func (r *BrowserFService) DeleteFile(ctx context.Context, id string, body Browse
8282 return
8383}
8484
85+ // Returns a ZIP file containing the contents of the specified directory.
86+ func (r * BrowserFService ) DownloadDirZip (ctx context.Context , id string , query BrowserFDownloadDirZipParams , opts ... option.RequestOption ) (res * http.Response , err error ) {
87+ opts = append (r .Options [:], opts ... )
88+ opts = append ([]option.RequestOption {option .WithHeader ("Accept" , "application/zip" )}, opts ... )
89+ if id == "" {
90+ err = errors .New ("missing required id parameter" )
91+ return
92+ }
93+ path := fmt .Sprintf ("browsers/%s/fs/download_dir_zip" , id )
94+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , query , & res , opts ... )
95+ return
96+ }
97+
8598// Get information about a file or directory
8699func (r * BrowserFService ) FileInfo (ctx context.Context , id string , query BrowserFFileInfoParams , opts ... option.RequestOption ) (res * BrowserFFileInfoResponse , err error ) {
87100 opts = append (r .Options [:], opts ... )
@@ -145,6 +158,32 @@ func (r *BrowserFService) SetFilePermissions(ctx context.Context, id string, bod
145158 return
146159}
147160
161+ // Allows uploading single or multiple files to the remote filesystem.
162+ func (r * BrowserFService ) Upload (ctx context.Context , id string , body BrowserFUploadParams , opts ... option.RequestOption ) (err error ) {
163+ opts = append (r .Options [:], opts ... )
164+ opts = append ([]option.RequestOption {option .WithHeader ("Accept" , "" )}, opts ... )
165+ if id == "" {
166+ err = errors .New ("missing required id parameter" )
167+ return
168+ }
169+ path := fmt .Sprintf ("browsers/%s/fs/upload" , id )
170+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodPost , path , body , nil , opts ... )
171+ return
172+ }
173+
174+ // Upload a zip file and extract its contents to the specified destination path.
175+ func (r * BrowserFService ) UploadZip (ctx context.Context , id string , body BrowserFUploadZipParams , opts ... option.RequestOption ) (err error ) {
176+ opts = append (r .Options [:], opts ... )
177+ opts = append ([]option.RequestOption {option .WithHeader ("Accept" , "" )}, opts ... )
178+ if id == "" {
179+ err = errors .New ("missing required id parameter" )
180+ return
181+ }
182+ path := fmt .Sprintf ("browsers/%s/fs/upload_zip" , id )
183+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodPost , path , body , nil , opts ... )
184+ return
185+ }
186+
148187// Write or create a file
149188func (r * BrowserFService ) WriteFile (ctx context.Context , id string , contents io.Reader , body BrowserFWriteFileParams , opts ... option.RequestOption ) (err error ) {
150189 opts = append (r .Options [:], opts ... )
@@ -266,6 +305,21 @@ func (r *BrowserFDeleteFileParams) UnmarshalJSON(data []byte) error {
266305 return apijson .UnmarshalRoot (data , r )
267306}
268307
308+ type BrowserFDownloadDirZipParams struct {
309+ // Absolute directory path to archive and download.
310+ Path string `query:"path,required" json:"-"`
311+ paramObj
312+ }
313+
314+ // URLQuery serializes [BrowserFDownloadDirZipParams]'s query parameters as
315+ // `url.Values`.
316+ func (r BrowserFDownloadDirZipParams ) URLQuery () (v url.Values , err error ) {
317+ return apiquery .MarshalWithSettings (r , apiquery.QuerySettings {
318+ ArrayFormat : apiquery .ArrayQueryFormatComma ,
319+ NestedFormat : apiquery .NestedQueryFormatBrackets ,
320+ })
321+ }
322+
269323type BrowserFFileInfoParams struct {
270324 // Absolute path of the file or directory.
271325 Path string `query:"path,required" json:"-"`
@@ -345,6 +399,70 @@ func (r *BrowserFSetFilePermissionsParams) UnmarshalJSON(data []byte) error {
345399 return apijson .UnmarshalRoot (data , r )
346400}
347401
402+ type BrowserFUploadParams struct {
403+ Files []BrowserFUploadParamsFile `json:"files,omitzero,required"`
404+ paramObj
405+ }
406+
407+ func (r BrowserFUploadParams ) MarshalMultipart () (data []byte , contentType string , err error ) {
408+ buf := bytes .NewBuffer (nil )
409+ writer := multipart .NewWriter (buf )
410+ err = apiform .MarshalRoot (r , writer )
411+ if err == nil {
412+ err = apiform .WriteExtras (writer , r .ExtraFields ())
413+ }
414+ if err != nil {
415+ writer .Close ()
416+ return nil , "" , err
417+ }
418+ err = writer .Close ()
419+ if err != nil {
420+ return nil , "" , err
421+ }
422+ return buf .Bytes (), writer .FormDataContentType (), nil
423+ }
424+
425+ // The properties DestPath, File are required.
426+ type BrowserFUploadParamsFile struct {
427+ // Absolute destination path to write the file.
428+ DestPath string `json:"dest_path,required"`
429+ File io.Reader `json:"file,omitzero,required" format:"binary"`
430+ paramObj
431+ }
432+
433+ func (r BrowserFUploadParamsFile ) MarshalJSON () (data []byte , err error ) {
434+ type shadow BrowserFUploadParamsFile
435+ return param .MarshalObject (r , (* shadow )(& r ))
436+ }
437+ func (r * BrowserFUploadParamsFile ) UnmarshalJSON (data []byte ) error {
438+ return apijson .UnmarshalRoot (data , r )
439+ }
440+
441+ type BrowserFUploadZipParams struct {
442+ // Absolute destination directory to extract the archive to.
443+ DestPath string `json:"dest_path,required"`
444+ ZipFile io.Reader `json:"zip_file,omitzero,required" format:"binary"`
445+ paramObj
446+ }
447+
448+ func (r BrowserFUploadZipParams ) MarshalMultipart () (data []byte , contentType string , err error ) {
449+ buf := bytes .NewBuffer (nil )
450+ writer := multipart .NewWriter (buf )
451+ err = apiform .MarshalRoot (r , writer )
452+ if err == nil {
453+ err = apiform .WriteExtras (writer , r .ExtraFields ())
454+ }
455+ if err != nil {
456+ writer .Close ()
457+ return nil , "" , err
458+ }
459+ err = writer .Close ()
460+ if err != nil {
461+ return nil , "" , err
462+ }
463+ return buf .Bytes (), writer .FormDataContentType (), nil
464+ }
465+
348466type BrowserFWriteFileParams struct {
349467 // Destination absolute file path.
350468 Path string `query:"path,required" json:"-"`
0 commit comments