API Reference

Use the upload method to upload a file.

try {
  const file = /* your file data */; // Your file input or Blob.
  const directoryId = 'directory_id_here'; // The ID of the target directory.
  const labels = ['label1', 'label2']; // An array of labels (optional).

  const [data, error] = await sdk.file.upload({
    file,
    directoryId,
    labels
  });

  // Check for success
  if (error) {
    console.error("Failed to upload the file:", error);
  } else {
    console.log("File uploaded successfully:", data);
  }
} catch (error) {
  console.error("An unexpected error occurred:", error.message);
}

Params

  • file (formData): The file data to be uploaded.
  • directoryId (string): The ID of the target directory.
  • labels (string[], optional): An array of labels. (Used for organizing and filtering files.)

Required API Key Permission

  • Upload File