POST
/
boxes
/
{boxId}
/
fs
/
write
JavaScript
import GboxSDK from "gbox-sdk";

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});

async function main() {
  const box = await gboxSDK.create({ type: "linux" });

  // Write a text file
  const writeResult = await box.fs.write({
    path: "/home/user/example.txt",
    content: "Hello, World!\nThis is a test file created with GboxSDK."
  });

  console.log(`Write result: ${writeResult.message}`);

  // Create a JSON configuration file
  const config = {
    name: "My Application",
    version: "1.0.0",
    settings: {
      debug: true,
      port: 3000
    }
  };

  await box.fs.write({
    path: "/home/user/config.json",
    content: JSON.stringify(config, null, 2)
  });

  console.log("Configuration file created successfully");
}

main();
{
  "type": "file",
  "name": "example.txt",
  "path": "/path/to/example.txt",
  "size": "10MB",
  "mode": "755",
  "lastModified": "2021-01-01T00:00:00Z"
}

Authorizations

Authorization
string
header
required

Enter your API Key in the format: Bearer <token>. Get it from https://gbox.ai

Path Parameters

boxId
string
required

Box ID

Example:

"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"

Body

multipart/form-data

Request parameters for writing content to a file

Response

200
application/json

Write file

File system file representation