diff --git a/.gitignore b/.gitignore
index d803c5f..78c175b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,4 @@
config.properties
.mvn
-.idea
target
-directory.db
-webdav.iml
\ No newline at end of file
+directory.db
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..3864f88
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..f19abed
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ sqlite.xerial
+ true
+ org.sqlite.JDBC
+ jdbc:sqlite:$PROJECT_DIR$/directory.db
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..63e9001
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..4b661a5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/top/dreamcenter/webdav/util/WebDavUtil.java b/src/main/java/top/dreamcenter/webdav/util/WebDavUtil.java
index e4abb3f..413d54c 100644
--- a/src/main/java/top/dreamcenter/webdav/util/WebDavUtil.java
+++ b/src/main/java/top/dreamcenter/webdav/util/WebDavUtil.java
@@ -6,6 +6,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -16,6 +17,8 @@ import top.dreamcenter.webdav.bean.SendResult;
import top.dreamcenter.webdav.prop.WebDavConfig;
import java.io.File;
+import java.net.URLEncoder;
+import java.util.Arrays;
/**
* WebDav工具
@@ -37,7 +40,7 @@ public class WebDavUtil {
.build();
try {
// 创建PUT请求
- HttpPut httpPut = new HttpPut(WebDavConfig.getUrl() + "/" + davName);
+ HttpPut httpPut = new HttpPut(WebDavConfig.getUrl() + "/" + encodeURL(davName));
FileEntity fileEntity = new FileEntity(file, ContentType.DEFAULT_BINARY); // 或者根据需要选择正确的ContentType
httpPut.setEntity(fileEntity);
// 执行请求
@@ -69,4 +72,9 @@ public class WebDavUtil {
private static String responseEntityToString(HttpEntity entity) throws Exception {
return EntityUtils.toString(entity, "UTF-8"); // 需要Apache HttpCore的依赖来使用这个方法
}
+
+ private static String encodeURL(String raw) {
+ String[] split = raw.split("/");
+ return URLEncodedUtils.formatSegments(split);
+ }
}
diff --git a/webdav.iml b/webdav.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/webdav.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file