The FileManagerS3Service
class provide a collection of methods to manage files and folders. The most common operations performed on files include uploading, downloading, deleting, coping, moving and searching from files, as well as creating and deleting folders for organising the work space.
File data model The File Manager Service uses the class FileClass
as the file data model. This class provides the following attributes:
{
id : number ;
name : string ;
size : number ;
creationDate : number ;
directory : boolean ;
}
Where the attributes indicates the following:
id : The file identifier. name : The file name. size : The file size. creationDate : Timestamp that represents the date of creation of the file. directory : Indicates wether a file is a folder or not. Methods Configure de Ontimize Web File Manager SDMS Service.
Name Type Required Description config Map yes The configuration object parameter
queryFiles Get the files in the work space.
Name Type Required Description workspaceId yes The work space identifier kv Object no A key/value object for filtering the results requested attrs string[] no An array of string wi the searching fields requested
Return Observable<FileClass[]> download Download de requested files.
Name Type Required Description workspaceId yes The work space identifier files FileClass[] yes The downloading files data
downloadMultiple Download de requested files in a zip file.
Name Type Required Description workspaceId yes The work space identifier files FileClass[] yes The downloading files data
upload Upload the provided files and place them in the provided flder.
Name Type Required Description workspaceId yes The work space identifier folderId yes The folder identifier files FileClass[] yes The downloading files data
deleteFiles Delete the provided files from the work space.
Name Type Required Description workspaceId yes The work space identifier files FileClass[] yes The downloading files data
insertFolder Create a folder in the work space.
Name Type Required Description workspaceId yes The work space identifier name string yes The folder name kv Map no A key/value object for filtering where the folder will be created
changeFileName Change the name of a file.
Name Type Required Description name string yes The new name of the file file FileClass yes The file to be name changed workspace WordspaceS3 yes The work space
copyFiles Copy files to a folder.
Name Type Required Description workspace WordspaceS3 yes The work space files FileClass[] yes The files to be copied folder string yes The final folder of the files copied kv Object no A key/value object for filtering the results requested
moveFiles Move files to a folder.
Name Type Required Description workspace WordspaceS3 yes The work space files FileClass[] yes The files to be copied folder string yes The final folder of the files copied kv Object no A key/value object for filtering the results requested
Extending the File Manager Service You can define your own file manager service by extending the FileManagerService
class as follows.
import { Injectable , Injector } from ' @angular/core ' ;
import { FileManagerS3Service } from ' ontimize-web-ngx-filemanager ' ;
@ Injectable ()
export class FileManagerExtendedService extends FileManagerS3Service {
constructor (
protected injector : Injector
) {
super ( injector );
}
}
File Manager REST API In this section we describe the REST API used by the FileManagerS3Service
.
Path : /queryFiles/:workspaceId Method : POST URL params : Name Type Description workspaceId any The work space identifier
Name Type Description queryParams Map A map with the search parameters definde as follows Name Type Description filter Map A key/value object for filtering the results requested attributes String[] Array containing the requested fields
Download a single file Path : /getFile/:fileId Method : GET URL params : Name Type Description fileId Array of files information for downloading
Download multiple files and/or folders Path : /getFiles/:workspaceId Method : POST URL params : Name Type Description workspaceId any The work space identifier
Name Type Description files FileClass[] A list of files data for downloading
Response : Map containing the zip file name generated. Download zip file Path : /getZipFile/:file Method : GET URL params : Name Type Description file string The file for downloading
Upload file Path : /insertFile/:workspaceId Method : POST URL params : Name Type Description workspaceId any The work space identifier
Name Type Description file The uploading file folderId The forlder identifier that will contains the file uploading file
Response : The inserted file identifier. Delete files and/or folders Path : /deleteFiles/:workspaceId Method : POST URL params : Name Type Description workspaceId any The work space identifier
Name Type Description deleteParams Map A map with the delete parameters defined as follows Name Type Description fileList FileClass[] A list of files data for deleting
Create folder Path : /insertFolder/:workspaceId/:folderName Method : POST URL params : Name Type Description workspaceId any The work space identifier name string The folder name
Name Type Description insertParams Map A map with the following parameters described as follows Name Type Description data Map A map with the insert extra information
Change file/folder name Path : /fileUpdate Method : POST Data params : Name Type Description fileParams Map A map with the following parameters described as follows Name Type Description file FileClass The file data for changing name params Map A map with a 'name' key containing the new name for the file