Skip to main content

rename-file

Description

Fires when renaming a file

Usage

"rename-file": ({
id: string,
name: string,
newId?: string
}) => void;

Parameters

The callback of the rename-file action takes an object with the following parameters:

  • id - (required) the ID of a renamed file
  • name - (required) the name of a renamed file
  • newId (optional) new generated ID of a renamed file (the readonly parameter, it's not recommended to set this parameter manually when calling actions)

The event handler for rename-file should not return any value. However, if it returns false, the rename operation will be blocked and the file or folder will retain its original name.

Example

<script>
import { getData, getDrive } from "./common/data";
import { Filemanager } from "wx-svelte-filemanager";

let api;

$: if (api) {
api.on("rename-file", ({ id, name }) => {
console.log(`${id} was renamed to ${name}`);
});
}

</script>

<Filemanager data={getData()} drive={getDrive()} bind:api />

Related articles: How to access File Manager API