Use the rename
method to rename a file.
try {
const id = 'file_id_here'; // The ID of the file to rename.
const name = 'new_file_name'; // The new name for the file.
const [data, error] = await sdk.file.rename({
id,
name
});
// Check for success
if (error) {
console.error('Failed to rename the file:', error);
} else {
console.log(`File renamed to: ${name}`);
}
} catch (error) {
console.error('An unexpected error occurred:', error.message);
}
Params
id
(string): The ID of the file you want to rename.name
(string): The new name for the file.
Required API Key Permission
Upload File
orDelete File