From bb8858b616cbf4ba414715036e7d72a6eec78868 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 31 Aug 2021 21:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=B8=BA=E9=93=BE=E6=8E=A5,=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/DirectLinkUpload.kt | 7 +++++-- .../java/io/legado/app/help/http/OkHttpUtils.kt | 4 ++-- .../app/ui/main/bookshelf/BaseBookshelfFragment.kt | 13 +++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt b/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt index cf5f88ee5..f9702d042 100644 --- a/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt +++ b/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt @@ -13,8 +13,11 @@ object DirectLinkUpload { suspend fun upLoad(fileName: String, byteArray: ByteArray): String { val res = okHttpClient.newCallStrResponse { - url("https://shuyuan.miaogongzi.site/index.html") - postMultipart(mapOf("file" to Triple(fileName, byteArray, null))) + url("https://shuyuan.miaogongzi.site/upload.php") + postMultipart( + "multipart/form-data", + mapOf("file" to Triple(fileName, byteArray, "application/json")) + ) } val analyzeRule = AnalyzeRule(RuleData()).setContent(res.body, res.url) return analyzeRule.getString("tag.b@text") diff --git a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt index 0d995fe23..91721c8e8 100644 --- a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt +++ b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt @@ -118,8 +118,8 @@ fun Request.Builder.postForm(form: Map, encoded: Boolean = false post(formBody.build()) } -fun Request.Builder.postMultipart(form: Map) { - val multipartBody = MultipartBody.Builder() +fun Request.Builder.postMultipart(type: String, form: Map) { + val multipartBody = MultipartBody.Builder().setType(type.toMediaType()) form.forEach { when (it.value) { is Triple<*, *, *> -> { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt index a203add69..a7c35b1ca 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt @@ -33,8 +33,17 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment + alert("导出成功") { + val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { + editView.hint = "路径" + editView.setText(uri.toString()) + } + customView { alertBinding.root } + okButton { + requireContext().sendToClip(uri.toString()) + } + }.show() } } abstract val groupId: Long