Updates a folder.
The updateFolder()
function returns a Promise that resolves to information about the updated folder.
You can use the parentFolderId
parameter to move a folder from its current parent folder to a different parent folder.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateFolder(
_id: string,
folder: UpdateFolder,
options: UpdateFolderOptions,
): Promise<Folder>;
Folder ID. Generated when a folder is created in the Media Manager.
Folder to update.
import { folders } from "wix-media.v2";
/* Sample id value: '7984b3c5454e4371aqbd4f4eedde96bc'
*
* Sample folder value:
* {
* displayName: 'mountains'
* }
*/
async function myUpdateFolderFunction(id, options) {
try {
const updatedFolder = await folders.updateFolder(id, options);
console.log(`Updated folder ${updatedFolder.displayName}:`, updatedFolder);
return updatedFolder;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "2023-08-21T09:32:34.000Z",
* "_id": "7984b3c5454e4371acbd4f4eedde96bc",
* "_updatedDate": "2023-08-21T11:10:51.000Z",
* "displayName": "mountains",
* "parentFolderId": "103601562ec94214bee61f470b403dd5",
* "state": "OK"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.