API Reference

Use the update method to modify access settings for a specific file.

try {
  const fileId = 'file_id_here'; // The ID of the file for which you want to modify access settings.
  const cid = 'content_identifier_here'; // The content identifier (CID) for accessing the file.
  
  // Define the access settings for the file.
  const accessSettings = {
    secureSharing: 'PUBLIC' // The desired access setting: 'PUBLIC', 'PASSWORD', or 'RESTRICTED'.
  };

  const [updateResult, error] = await sdk.fileAccess.update({
    fileId,
    cid,
    body: accessSettings
  });

  // Check for success
  if (error) {
    console.error('Failed to update access settings:', error);
  } else {
    console.log('Access settings updated successfully:', updateResult);
  }
} catch (error) {
  console.error('An unexpected error occurred while updating access settings:', error.message);
}

Params

  • fileId (string): The ID of the file for which you want to verify access.
  • cid (string): The content identifier (CID) for accessing the file.
  • body (object): An object containing the desired access setting (secureSharing can be 'PUBLIC', 'PASSWORD', or 'RESTRICTED').

Required API Key Permission

  • Upload File