POST /v1/agents/runtime/{runtime_id}/files?path=... (multipart)
import io
from gravixlayer import GravixLayer
client = GravixLayer() # defaults to cloud="aws", region="us-east-1"
sandbox = client.runtime.create() # defaults to template="base-small"
# Upload from a file-like object (any binary stream)
buffer = io.BytesIO(b"hello from local upload\n")
response = sandbox.file.upload_file(buffer, path="/workspace/local-file.txt")
print(response.message)
print(response.path)
print(response.size)
# Or upload bytes/string directly with `upload` (no file handle required)
sandbox.file.upload("/workspace/notes.txt", b"plain text bytes\n")
sandbox.kill()
import { readFile } from 'node:fs/promises';
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer(); // defaults to cloud="aws", region="us-east-1"
const sandbox = await client.runtime.create(); // defaults to template="base-small"
// Multipart upload from a Buffer (local file, bytes, or string)
const buffer = Buffer.from('hello from local upload\n');
const response = await sandbox.file.uploadFile(buffer, '/workspace/local-file.txt');
console.log(response.message);
console.log(response.path);
console.log(response.size);
await sandbox.file.upload('/workspace/notes.txt', 'plain text bytes\n');
// Or read a local file and upload it
const local = await readFile('./local.py');
await sandbox.file.upload('/workspace/local.py', local);
await sandbox.kill();
gravixlayer runtime files upload "$RT" ./local.py /workspace/local.py
curl -X POST "https://api.gravixlayer.ai/v1/agents/runtime/$RT/files?path=/workspace/local.py" \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-F "file=@./local.py"
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file | BinaryIO | Yes | File object opened in binary mode |
path | string | No | Destination path inside runtime |
Response
| Field | Type | Description |
|---|---|---|
message | string | Confirmation message |
path | string | Uploaded file path |
size | integer | File size in bytes |