Skip to main content

loadInfo()

Description

Gets a promise with an object with the information on file system (total and used space)
info

The loadInfo() method is a part of the RestDataProvider service intended for working with the server

Usage

loadInfo(id?: string): Promise<void | obj[]>; 

Parameters

id - (optional) the id of a folder where data about folder will be loaded (which is a path to the folder)

Returns

The loadInfo() method returns a promise with the data on file system.

If the id parameter is sent in the request line the response will we as in the example below:

{
"Size": 47597382, // the folder size
"Count": 17 // the number of items in the folder
}

If the id parameter is not sent in the request then the method returns an object as in the example below:

{
"free": 0,
"total": 467300933632,
"used": 229621727232
}

Examples

<script>
import { RestDataProvider } from "wx-filemanager-data-provider";
import { Filemanager } from "wx-svelte-filemanager";

const url = "https://some-backend-url";

const restProvider = new RestDataProvider(url);
let fmApi;

$: data = [];
$: drive = {};

function init(api) {
fmApi = api;
api.setNext(restProvider);
}

Promise.all([restProvider.loadFiles(), restProvider.loadInfo()]).then(([files, info]) => {
data = files;
drive = info.stats;
});

</script>

<Filemanager
{init}
{data}
{drive} />

Related articles: