Use the update
method to update information about a file
try {
const fileId = 'file_id_here'; // The ID of the file to update.
const newName = 'new_file_name.txt'; // The new name for the file (optional).
const addStorageClasses = ['class1', 'class2']; // Additional storage classes (optional).
const removeStorageClasses = ['class3', 'class4']; // Storage classes to remove (optional).
const [data, error] = await sdk.file.update({
fileId,
newName,
addStorageClasses,
removeStorageClasses
});
// Check for success
if (error) {
console.error('Failed to update file information:', error);
} else {
console.log('File information updated successfully:', data);
}
} catch (error) {
console.error('An unexpected error occurred:', error.message);
}
Params
fileId
(string): The ID of the file you want to rename.newName
(string, optional): The new name for the file.addStorageClasses
(string[], optional): An array of additional - storage classes.removeStorageClasses
(string[], optional): An array of storage classes to remove.
Required API Key Permission
Upload File
orDelete File