Filesystem
Compose multiple files into a single file using zero-copy concatenation. Source files are deleted after successful composition.
POST
/
files
/
compose
Compose multiple files into a single file using zero-copy concatenation. Source files are deleted after successful composition.
curl --request POST \
--url https://{port}-{sandboxID}.e2b.app/files/compose \
--header 'Content-Type: application/json' \
--header 'X-Access-Token: <api-key>' \
--data '
{
"source_paths": [
"<string>"
],
"destination": "<string>",
"username": "<string>"
}
'import requests
url = "https://{port}-{sandboxID}.e2b.app/files/compose"
payload = {
"source_paths": ["<string>"],
"destination": "<string>",
"username": "<string>"
}
headers = {
"X-Access-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Access-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({source_paths: ['<string>'], destination: '<string>', username: '<string>'})
};
fetch('https://{port}-{sandboxID}.e2b.app/files/compose', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{port}-{sandboxID}.e2b.app/files/compose",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'source_paths' => [
'<string>'
],
'destination' => '<string>',
'username' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{port}-{sandboxID}.e2b.app/files/compose"
payload := strings.NewReader("{\n \"source_paths\": [\n \"<string>\"\n ],\n \"destination\": \"<string>\",\n \"username\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Access-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{port}-{sandboxID}.e2b.app/files/compose")
.header("X-Access-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"source_paths\": [\n \"<string>\"\n ],\n \"destination\": \"<string>\",\n \"username\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{port}-{sandboxID}.e2b.app/files/compose")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Access-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"source_paths\": [\n \"<string>\"\n ],\n \"destination\": \"<string>\",\n \"username\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"path": "<string>",
"name": "<string>"
}{
"message": "path '/home/user/docs' is a directory",
"code": 400
}{
"message": "error looking up user 'nonexistent': user: unknown user nonexistent",
"code": 401
}{
"message": "path '/home/user/missing.txt' does not exist",
"code": 404
}{
"message": "error opening file '/home/user/file.txt': permission denied",
"code": 500
}{
"message": "<string>",
"code": 123,
"sandboxID": "<string>"
}{
"message": "not enough disk space available",
"code": 507
}Authorizations
Sandbox access token (envdAccessToken) for authenticating requests to a running sandbox. Returned by: POST /sandboxes (on create), POST /sandboxes/{sandboxID}/connect (on connect), POST /sandboxes/{sandboxID}/resume (on resume), and GET /sandboxes/{sandboxID} (for running or paused sandboxes).
Body
application/json
Was this page helpful?
⌘I
Compose multiple files into a single file using zero-copy concatenation. Source files are deleted after successful composition.
curl --request POST \
--url https://{port}-{sandboxID}.e2b.app/files/compose \
--header 'Content-Type: application/json' \
--header 'X-Access-Token: <api-key>' \
--data '
{
"source_paths": [
"<string>"
],
"destination": "<string>",
"username": "<string>"
}
'import requests
url = "https://{port}-{sandboxID}.e2b.app/files/compose"
payload = {
"source_paths": ["<string>"],
"destination": "<string>",
"username": "<string>"
}
headers = {
"X-Access-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Access-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({source_paths: ['<string>'], destination: '<string>', username: '<string>'})
};
fetch('https://{port}-{sandboxID}.e2b.app/files/compose', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{port}-{sandboxID}.e2b.app/files/compose",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'source_paths' => [
'<string>'
],
'destination' => '<string>',
'username' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{port}-{sandboxID}.e2b.app/files/compose"
payload := strings.NewReader("{\n \"source_paths\": [\n \"<string>\"\n ],\n \"destination\": \"<string>\",\n \"username\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Access-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{port}-{sandboxID}.e2b.app/files/compose")
.header("X-Access-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"source_paths\": [\n \"<string>\"\n ],\n \"destination\": \"<string>\",\n \"username\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{port}-{sandboxID}.e2b.app/files/compose")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Access-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"source_paths\": [\n \"<string>\"\n ],\n \"destination\": \"<string>\",\n \"username\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"path": "<string>",
"name": "<string>"
}{
"message": "path '/home/user/docs' is a directory",
"code": 400
}{
"message": "error looking up user 'nonexistent': user: unknown user nonexistent",
"code": 401
}{
"message": "path '/home/user/missing.txt' does not exist",
"code": 404
}{
"message": "error opening file '/home/user/file.txt': permission denied",
"code": 500
}{
"message": "<string>",
"code": 123,
"sandboxID": "<string>"
}{
"message": "not enough disk space available",
"code": 507
}