package com.uas.ops.diff.service; import com.uas.ops.diff.util.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.FileCopyUtils; import java.io.File; import java.io.IOException; import java.util.UUID; /** * Created by Pro1 on 2017/6/13. */ //@Service @Deprecated public class LocalFileService implements FileService{ @Value("${diff.home}") private String appHome; @Override public String save(byte[] data, String fileName) throws IOException{ String name = StringUtils.uuid(); FileCopyUtils.copy(data, new File(appHome, name)); return name; } @Override public byte[] get(String path) throws IOException { File file = new File(appHome, path); if (file.exists()) { return FileCopyUtils.copyToByteArray(file); } return null; } @Override public void delete(String path) { File file = new File(appHome, path); if (file.exists()) { file.delete(); } } }