mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
适配WebDAV ing
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.auth.v.GlobalConstant;
|
||||
import cn.hellohao.config.GlobalConstant;
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
@@ -8,9 +7,7 @@ import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.service.ImgService;
|
||||
import cn.hellohao.service.KeysService;
|
||||
import cn.hellohao.utils.Print;
|
||||
import cn.hellohao.utils.TypeDict;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.github.sardine.impl.methods.HttpMkCol;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
@@ -154,7 +151,6 @@ public class WebDAVImageupload {
|
||||
}
|
||||
|
||||
public Boolean delWebDAV(Integer keyID, Images images) {
|
||||
CloseableHttpClient httpClient = (CloseableHttpClient)GlobalConstant.KeyMap.get(keyID).getObject();
|
||||
boolean b = true;
|
||||
try {
|
||||
Keys keys = keysService.selectKeys(images.getSource());
|
||||
@@ -179,22 +175,16 @@ public class WebDAVImageupload {
|
||||
}
|
||||
|
||||
|
||||
public ResponseEntity<InputStreamResource> getWebDAV(String shortUuid,String brieflink) {
|
||||
public ResponseEntity<InputStreamResource> getWebDAV(String shortUuid) {
|
||||
boolean b = true;
|
||||
try {
|
||||
Images images = null;
|
||||
if(StringUtils.isBlank(shortUuid)){
|
||||
images = imgService.selectImgByBrieflink(brieflink);
|
||||
}else{
|
||||
// images = imgService.selectImgUrlByImgUID(imgUID);
|
||||
images = imgService.selectImgByShortlink(shortUuid);
|
||||
}
|
||||
images = imgService.selectImgByShortlink(shortUuid);
|
||||
Keys keys = keysService.selectKeys(images.getSource());
|
||||
String rootPath = keys.getRootPath().equals("/")?"":keys.getRootPath();
|
||||
String fileUrl = StringUtils.isBlank(shortUuid)?keys.getEndpoint()+"/"+images.getBriefimgname():keys.getEndpoint()+"/"+images.getImgname();
|
||||
String fileUrl = keys.getEndpoint()+"/"+images.getImgname();
|
||||
HttpGet httpGet = new HttpGet(fileUrl);
|
||||
HttpResponse response = httpClient.execute(httpGet);
|
||||
|
||||
// if (sardine.exists(keys.getEndpoint() + images.getImgname())) {
|
||||
// InputStream inputStream = sardine.get(keys.getEndpoint() + images.getImgname());
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
@@ -112,17 +112,29 @@ public class FirstRun implements InitializingBean {
|
||||
Print.Normal("Add table.confdata");
|
||||
}
|
||||
Integer ret7 =
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'SysTransmit' and column_name = 'keys'");
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'keys' and column_name = 'SysTransmit'");
|
||||
if (ret7 == 0) {
|
||||
RunSqlScript.RunInsert(sql7);
|
||||
Print.Normal("Add keys.SysTransmit");
|
||||
}
|
||||
Integer ret8 =
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'brieflink' and column_name = 'imgdata'");
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'imgdata' and column_name = 'brieflink'");
|
||||
if (ret8 == 0) {
|
||||
RunSqlScript.RunInsert(sql8);
|
||||
Print.Normal("Add imgdata.brieflink");
|
||||
}
|
||||
Integer ret9 =
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'imgdata' and column_name = 'shortlink'");
|
||||
if (ret9 == 0) {
|
||||
RunSqlScript.RunInsert(sql9);
|
||||
Print.Normal("Add imgdata.shortlink");
|
||||
}
|
||||
Integer ret10 =
|
||||
RunSqlScript.RunSelectCount(" select count(*) from tbed.keys where storageType='9'");
|
||||
if (ret10 == 0) {
|
||||
RunSqlScript.RunInsert(sql10);
|
||||
Print.Normal("Add Webdav Config");
|
||||
}
|
||||
RunSqlScript.RunInsert(index_imgdata);
|
||||
RunSqlScript.RunInsert("ALTER TABLE tbed.`user` MODIFY id int auto_increment;");
|
||||
Print.Normal("Stage success");
|
||||
@@ -145,8 +157,9 @@ public class FirstRun implements InitializingBean {
|
||||
private String sql7 =
|
||||
"alter table `keys` add SysTransmit varchar(50) DEFAULT NULL ;";
|
||||
private String sql8 = "alter table `imgdata` add brieflink varchar(100) DEFAULT null ;";
|
||||
private String sql9 = "alter table `imgdata` add shortlink varchar(100) DEFAULT null ;";
|
||||
// 图片标识名字段
|
||||
private String sql11 = "alter table `imgdata` add idname varchar(255) DEFAULT '未命名' ;";
|
||||
private String sql10 = "INSERT INTO `tbed`.`keys`(`id`, `AccessKey`, `AccessSecret`, `Endpoint`, `Bucketname`, `RequestAddress`, `storageType`, `keyname`, `Region`, `RootPath`, `SysTransmit`) VALUES (null, '账号', '密码', '连接', '', '存储源请求域名', 9, 'WebDAV', NULL, '/', NULL);";
|
||||
|
||||
private String sql12 = "alter table tbed.user add `token` varchar(255)";
|
||||
//创建客户端程序相关表
|
||||
|
||||
Reference in New Issue
Block a user