@runloop/api-client - v1.4.0
    Preparing search index...

    Class DevboxFileOps

    File operations for a devbox. Provides methods for reading, writing, uploading, and downloading files.

    Index

    Methods

    • Read file contents from the devbox as a UTF-8 string.

      Parameters

      Returns Promise<string>

      File contents as a string

      const content = await devbox.file.read({ path: '/app/config.json' });
      const config = JSON.parse(content);
    • Download file contents (supports binary files).

      Parameters

      • params: DevboxDownloadFileParams

        Parameters containing the file path

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<Response>

      Download file response

      const response = await devbox.file.download({ path: '/app/data.bin' });
      const blob = await response.blob();
      // Process binary data...
    • Upload a file to the devbox.

      Parameters

      • params: DevboxUploadFileParams

        Parameters containing the file path and file to upload

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<unknown>

      Upload result

      const file = new File(['content'], 'data.txt');
      await devbox.file.upload({
      path: '/app/data.txt',
      file: file,
      });