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

import { useEffect, useState } from "react";
import { RestDataProvider } from "@svar-ui/filemanager-data-provider";
import { Filemanager } from "@svar-ui/react-filemanager";

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

const restProvider = new RestDataProvider(url);

export default function App() {
const [data, setData] = useState([]);
const [drive, setDrive] = useState({});

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

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

return <Filemanager init={init} data={data} drive={drive} />;
}

Related articles: