FileService

In this article:

Introduction

This file service works in scope a certain path like property FileAdminRootPaths which was set in properties.file. So, we can control different files in this scope. In order to init FileService need to use - Imcms.getServices().getManagedBean(FileService.class)

Use API

List<SourceFile> getRootFiles();

List<SourceFile> getFiles(Path file) throws IOException;

SourceFile getFile(Path file) throws IOException;

List<DocumentDTO> getDocumentsByTemplatePath(Path template) throws IOException;

void deleteFile(Path file) throws IOException;

List<SourceFile> moveFile(List<Path> src, Path target) throws IOException;

SourceFile moveFile(Path src, Path target) throws IOException;

List<SourceFile> copyFile(List<Path> src, Path target) throws IOException;

SourceFile saveFile(Path location, byte[] contents, OpenOption writeMode) throws IOException;

Template saveTemplateInGroup(Path template, String templateGroupName) throws IOException;

SourceFile createFile(SourceFile file, boolean isDirectory) throws IOException;

void replaceDocsOnNewTemplate(Path oldTemplate, Path newTemplate);

About parameter Path need to read documentation about nio2 here.

Fields in SourceFile

  1. String fileName;
  2. String physicalPath;
  3. String fullPath;
  4. FileType fileType; - DIRECTORY, FILE
  5. byte[] contents;
  6. String size;