Skip to content

Commit

Permalink
适配WebDAV ing
Browse files Browse the repository at this point in the history
  • Loading branch information
Hello-hao committed Jan 22, 2024
1 parent 48b0e1c commit f02d865
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
16 changes: 3 additions & 13 deletions src/main/java/cn/hellohao/service/impl/WebDAVImageupload.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
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;
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;
Expand Down Expand Up @@ -154,7 +151,6 @@ public static Integer Initialize(Keys k) {
}

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());
Expand All @@ -179,22 +175,16 @@ public Boolean delWebDAV(Integer keyID, Images images) {
}


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();
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/cn/hellohao/utils/FirstRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,29 @@ public void afterPropertiesSet() {
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");
Expand All @@ -145,8 +157,9 @@ public void afterPropertiesSet() {
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)";
//创建客户端程序相关表
Expand Down

0 comments on commit f02d865

Please sign in to comment.