com.sippnex.fileblade.service.FileService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fileblade-server Show documentation
Show all versions of fileblade-server Show documentation
Server-side Spring library for fileblade. A web filemanager
package com.sippnex.fileblade.service;
import com.sippnex.fileblade.domain.FbFile;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Service
public class FileService {
@Value("${fileblade.root:fileblade}")
private String rootPath;
public FbFile readFile(String pathString) throws IOException {
Path path = Paths.get(rootPath + pathString);
return new FbFile(pathString, Files.readAllBytes(path));
}
public void writeFile(FbFile file) throws IOException {
Path path = Paths.get(rootPath + file.getPath());
Files.write(path, file.getContent());
}
}