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 email = "[email protected]"; // The email of the user you want to invite.

  const [data, error] = await sdk.fileAccess.add({
    fileId,
    cid,
    body: { email } // Adding the email for invite-only access.
  });

  // Check for success
  if (error) {
    console.error("Failed to add email for invite-only access:", error);
  } else {
    console.log("Email added for invite-only access:", 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