Update files and folders
Change the name of a file or folder
The secrecyClient.cloud.updateNode
function is designed to rename a file or folder in the cloud. It takes a name and a nodeId as inputs to proceeds with the renaming operation.
cloud.ts
const changeNameFileOrFolder = async (
newName: string,
nodeId: string
): Promise<NodeFull | null> => {
// First we need to check if the secrecyClient is available
if (!secrecyClient) {
return null;
}
try {
const node = await secrecyClient.cloud.updateNode({
nodeId: nodeId,
name: name,
});
return node;
} catch (error) {
console.error(error);
return null;
}
};
Set a file or folder to favorite
The secrecyClient.cloud.updateNode
function is also used to mark a file or folder as a favorite in the cloud. It takes two parameters: isFavorite (a boolean indicating whether the item should be marked as a favorite) and nodeId (the ID of the file or folder).
cloud.ts
const setFileOrFolderToFavorite = async (
isFavorite: boolean,
nodeId: string
): Promise<NodeFull | null> => {
// First we need to check if the secrecyClient is available
if (!secrecyClient) {
return null;
}
try {
const node = await secrecyClient.cloud.updateNode({
nodeId: nodeId,
isFavorite: isFavorite,
});
return node;
} catch (error) {
console.error(error);
return null;
}
};