API Reference

Use the add method to enable file protection via password or invite-only via emails.

try {
  const fileId = 'file_id_here'; // The ID of the file to grant access to.
  const cid = 'content_identifier_here'; // The CID for accessing the file.
  const password = "access_password"; // The password to access the file.

  const [data, error] = await sdk.fileAccess.add({
    fileId,
    cid,
    body: { password }, // Setting the password for file access.
  });

  // Check for success
  if (error) {
    console.error("Failed to set password protection:", error);
  } else {
    console.log("Password protection added:", data);
  }
} catch (error) {
  console.error("An unexpected error occurred:", error.message);
}

Params

  • fileId (string): The ID of the file you want to grant access to.
  • cid (string): The content identifier (CID) for accessing the file.
  • body (object): An object containing access information, including an optional email and password.

Required API Key Permission

  • Upload File