Ctrl + K

File Listing

Explore files and directories in your sandbox with detailed metadata and flexible filtering options.

Basic Listing

const result = await sandbox.files.list({
  dirPath: '/opt/app'
});

result.files.forEach(file => {
  console.log(`${file.type}: ${file.name} (${file.size} bytes)`);
});
const response = await fetch(`${sandbox.url}/files/list`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    dirPath: '/opt/app'
  })
});

const result = await response.json();
curl -X POST https://sandbox.oblien.com/files/list \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "dirPath": "/opt/app"
  }'

Response:

{
  "success": true,
  "files": [
    {
      "name": "src",
      "path": "/opt/app/src",
      "type": "directory",
      "size": 4096,
      "modified": "2025-10-26T12:00:00Z"
    },
    {
      "name": "package.json",
      "path": "/opt/app/package.json",
      "type": "file",
      "size": 1245,
      "modified": "2025-10-26T11:30:00Z"
    }
  ],
  "path": "/opt/app",
  "total": 2
}

File Metadata

Each file entry includes:

FieldTypeDescription
namestringFile or directory name
pathstringFull absolute path
typestring"file" or "directory"
sizenumberSize in bytes
modifiedstringLast modified timestamp (ISO 8601)

Listing Options

Recursive Listing

List all files including subdirectories:

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  recursive: true
});

Ignore Patterns

Exclude files and directories by pattern:

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  recursive: true,
  ignorePatterns: ['node_modules', '.git', 'dist', '*.log']
});

Nested Structure

Get a nested directory tree:

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  recursive: true,
  nested: true
});

// Returns hierarchical structure

Light Mode

Get minimal information (faster for large directories):

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  light: true
});

Use .gitignore

Respect .gitignore patterns:

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  recursive: true,
  useGitignore: true
});

Path Filter

Filter results by path substring:

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  recursive: true,
  pathFilter: 'component'
});

// Only returns paths containing 'component'

Include File Hash

Include file content hash:

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  includeHash: true
});

Include Content

Include file content in listing:

const result = await sandbox.files.list({
  dirPath: '/opt/app',
  includeContent: true,
  maxContentSize: 1000000 // 1MB max
});

Complete Example

const result = await sandbox.files.list({
  dirPath: '/opt/app/src',
  recursive: true,
  ignorePatterns: ['node_modules', '*.test.js'],
  useGitignore: true,
  pathFilter: 'component'
});

console.log(`Found ${result.total} files`);
result.files.forEach(file => {
  if (file.type === 'file') {
    console.log(`  ${file.path}`);
  }
});
const response = await fetch(`${sandbox.url}/files/list`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    dirPath: '/opt/app/src',
    recursive: true,
    ignorePatterns: ['node_modules', '*.test.js'],
    useGitignore: true,
    pathFilter: 'component'
  })
});

const result = await response.json();
curl -X POST https://sandbox.oblien.com/files/list \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json"

All Parameters

ParameterTypeDefaultDescription
dirPathstringrequiredDirectory to list
recursivebooleanfalseInclude subdirectories
ignorePatternsstring[][]Patterns to ignore
nestedbooleanfalseReturn nested structure
lightbooleanfalseMinimal info only
flattenResultsbooleantrueFlatten nested results
maxDepthnumberunlimitedMax recursion depth
useGitignorebooleanfalseRespect .gitignore
pathFilterstring-Filter by path substring
includeHashbooleanfalseInclude file hash
includeContentbooleanfalseInclude file content
maxContentSizenumber1MBMax content size

Best Practices

  1. Use ignore patterns for large directories:

    ignorePatterns: ['node_modules', '.git', 'dist']
  2. Enable light mode for performance: Use light: true when you only need paths

  3. Respect .gitignore: Set useGitignore: true to skip ignored files

  4. Limit recursion depth: Use maxDepth for deep directory trees

Next Steps