Commit bb6760a5 authored by Menethil's avatar Menethil
Browse files

Merge remote-tracking branch 'origin/master'

parents 4b12f490 ab454046
......@@ -4,7 +4,6 @@ import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
import java.nio.file.Path;
import java.util.Map;
import java.util.stream.Stream;
/**
......@@ -13,7 +12,6 @@ import java.util.stream.Stream;
public class StorageService {
private String active;
private Storage storage;
private Map<String, Storage> supportedStorage;
public String getActive() {
return active;
......@@ -21,15 +19,14 @@ public class StorageService {
public void setActive(String active) {
this.active = active;
this.storage = this.supportedStorage.get(active);
}
public Map<String, Storage> getSupportedStorage() {
return supportedStorage;
public Storage getStorage() {
return storage;
}
public void setSupportedStorage(Map<String, Storage> supportedStorage) {
this.supportedStorage = supportedStorage;
public void setStorage(Storage storage) {
this.storage = storage;
}
/**
......
......@@ -22,12 +22,21 @@ public class StorageAutoConfiguration {
public StorageService storageService() {
StorageService storageService = new StorageService();
Map<String, Storage> supportedStorage = new HashMap<String, Storage>(3);
supportedStorage.put("local", localStorage());
supportedStorage.put("aliyun", aliyunStorage());
supportedStorage.put("tencent", tencentStorage());
storageService.setSupportedStorage(supportedStorage);
String active = this.properties.getActive();
storageService.setActive(active);
if(active.equals("local")){
storageService.setStorage(localStorage());
}
else if(active.equals("aliyun")){
storageService.setStorage(aliyunStorage());
}
else if(active.equals("tencent")){
storageService.setStorage(tencentStorage());
}
else{
throw new RuntimeException("当前存储模式 " + active + " 不支持");
}
return storageService;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment