|
|
@ -144,19 +144,20 @@ class WebDav(urlStr: String) { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据自己的URL,在远程处创建对应的文件夹 |
|
|
|
* 根据自己的URL,在远程处创建对应的文件夹 |
|
|
|
* |
|
|
|
|
|
|
|
* @return 是否创建成功 |
|
|
|
* @return 是否创建成功 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
suspend fun makeAsDir(): Boolean { |
|
|
|
suspend fun makeAsDir(): Boolean { |
|
|
|
val url = httpUrl |
|
|
|
val url = httpUrl |
|
|
|
val auth = HttpAuth.auth |
|
|
|
val auth = HttpAuth.auth |
|
|
|
if (url != null && auth != null) { |
|
|
|
if (url != null && auth != null) { |
|
|
|
okHttpClient.newCall { |
|
|
|
//防止报错 |
|
|
|
url(url) |
|
|
|
return kotlin.runCatching { |
|
|
|
method("MKCOL", null) |
|
|
|
okHttpClient.newCall { |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
url(url) |
|
|
|
} |
|
|
|
method("MKCOL", null) |
|
|
|
return true |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.isSuccess |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|