React FileManager - Custom.Configuration
This section describes properties that configure a custom file system provider.
abortFileUpload
A function that cancels the file upload.
The file that is being uploaded.
Information about the file upload session.
The directory where a file system item is uploaded to.
A Promise that is resolved after the file upload in aborted. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- abortFileUpload,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function abortFileUpload(fileData, chunksInfo, destinationDir) {
- // ...
- }
- // other functions
- export default App;
copyItem
A function that copies files or folders.
The current file system item.
The directory where a file system item is copied to.
A Promise that is resolved after the file system item is copied. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- copyItem,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function copyItem(item, destinationDir) {
- // ...
- }
- // other functions
- export default App;
createDirectory
A function that creates a directory.
The parent directory where a new directory should be created.
The name of the new directory.
A Promise that is resolved after a new directory is created. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- createDirectory,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function createDirectory(parentDir, name) {
- // ...
- }
- // other functions
- export default App;
dateModifiedExpr
Specifies which data field provides timestamps that indicate when a file was last modified.
deleteItem
A function that deletes a file or folder.
The current file system item.
A Promise that is resolved after a file system item is deleted. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- deleteItem,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function deleteItem(item) {
- // ...
- }
- // other functions
- export default App;
downloadItems
A function that downloads files.
The file system items.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- downloadItems,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function downloadItems(Array<FileManagerItem>) {
- // ...
- }
- // other functions
- export default App;
getItems
A function that gets file system items.
The directory that stores file system items.
A Promise that is resolved after file system items are obtained. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- getItems,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function getItems(pathInfo) {
- // ...
- }
- // other functions
- export default App;
getItemsContent
A function that get items content.
The file system items.
A Promise that is resolved after the content of the file system items is obtained. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- getItemsContent,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function getItemsContent(pathInfo) {
- // ...
- }
- // other functions
- export default App;
hasSubDirectoriesExpr
A function or the name of a data source field that provides information on whether a file or folder contains sub directories.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- hasSubDirectoriesExpr: "hasSubDirectoriesExpr",
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- export default App;
isDirectoryExpr
Specifies which data field provides information about whether a file system item is a directory.
moveItem
A function that moves files and folders.
The current file system item.
The directory where a file system item is moved to.
A Promise that is resolved after the file system item is moved. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- moveItem,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function moveItem(item, destinationDir) {
- // ...
- }
- // other functions
- export default App;
renameItem
A function that renames files and folders.
The current file system item.
The new name for the file system item.
A Promise that is resolved after the file system item is renamed. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- this.fileSystemProvider = new CustomFileSystemProvider({
- renameItem,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function renameItem(item, name) {
- // ...
- }
- // other functions
- export default App;
thumbnailExpr
Specifies which data field provides icons to be used as thumbnails.
The data field can contain one of the following:
- The icon's URL
- The icon's name if the icon is from the DevExtreme icon library
- The icon's CSS class if the icon is from an external icon library (see External Icon Libraries)
- The icon in the Base64 format
uploadFileChunk
A function that uploads a file in chunks.
The file that is being uploaded.
Information about the file upload session.
The directory where a file system item is uploaded to.
A Promise that is resolved after the file system item is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import FileManager from 'devextreme-react/file-manager';
- import CustomFileSystemProvider from 'devextreme/file_management/custom_provider';
- class App extends React.Component {
- render() {
- constructor() {
- super();
- gateway = new AzureGateway(endpointUrl, this.onRequestExecuted);
- azure = new AzureFileSystem(gateway);
- this.fileSystemProvider = new CustomFileSystemProvider({
- uploadFileChunk,
- // ...
- });
- }
- return (
- <FileManager
- fileSystemProvider={fileSystemProvider}>
- </FileManager>
- );
- }
- }
- function uploadFileChunk(fileData, uploadInfo, destinationDirectory) {
- let promise = null;
- if (uploadInfo.chunkIndex === 0) {
- const filePath = destinationDirectory.path ? `${destinationDirectory.path}/${fileData.name}` : fileData.name;
- promise = gateway.getUploadAccessUrl(filePath).done((accessUrl) => {
- uploadInfo.customData.accessUrl = accessUrl;
- });
- } else {
- promise = Promise.resolve();
- }
- promise = promise.then(() => gateway.putBlock(
- uploadInfo.customData.accessUrl,
- uploadInfo.chunkIndex,
- uploadInfo.chunkBlob,
- ));
- if (uploadInfo.chunkIndex === uploadInfo.chunkCount - 1) {
- promise = promise.then(() => gateway.putBlockList(
- uploadInfo.customData.accessUrl,
- uploadInfo.chunkCount,
- ));
- }
- return promise;
- }
- // other functions
- export default App;