api.getFile()
Description
Allows getting data for a file or folderUsage
api.getFile (
id: string
): object;
Parameters
id
- the requested file ID
Returns
An object that is returned has the following parameters:
id
(string) - (required) the ID of an itemdate
- (required) the Date object that represents the date of the entitytype
- (optional) the type which can be "file" or "folder"lazy
- (optional) when set to true for the "folder" items, indicates that their content needs to be requested separatelyparent
(string) - (optional) the parent folder of an item for which data is providedname
(string) - (optional) the name of a file/folderext
(string) - (optional) - file extensionopen
(boolean) - (optional) if set to true, the folder that is added will be opened; otherwise, falsedata
(array) - (optional) an array of objects with data for other items with the same parameters listed above for the item object
The object that is returned is as in the example below:
data:null
date:Thu Nov 30 2023 06:13:00 GMT+0300 {}
ext:"txt"
id:"/Info.txt"
name:"Info.txt"
parent:"/"
size:1000
type:"file"
Example
<script>
import { Filemanager } from "wx-svelte-filemanager";
import { getData } from "./common/data";
let api;
function logSelection() {
const id = api.getState().selected[0]; // get selected id
alert(api.getFile(id).name); // show the file name
}
</script>
<Filemanager
bind:api
on:select-file={logSelection} />
Related articles: