| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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();
- }
- }
- }
|