All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sippnex.fileblade.service.FileService Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
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());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy