web传书保存到用户位置的位置

pull/1595/head
Xwite 3 years ago
parent 8628f35ff5
commit b219ae533f
  1. 5
      app/src/main/java/io/legado/app/api/controller/BookController.kt

@ -7,6 +7,7 @@ import io.legado.app.api.ReturnData
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
import io.legado.app.help.CacheManager
import io.legado.app.help.ContentProcessor
@ -206,7 +207,9 @@ object BookController {
?: return returnData.setErrorMsg("fileName 不能为空")
val fileData = parameters["fileData"]?.firstOrNull()
?: return returnData.setErrorMsg("fileData 不能为空")
val file = FileUtils.createFileIfNotExist(LocalBook.cacheFolder, fileName)
if (AppConfig.defaultBookTreeUri == null) return returnData.setErrorMsg("没有设置书籍保存位置!")
val bookFolder = FileUtils.createFolderIfNotExist(AppConfig.defaultBookTreeUri!!)
val file = FileUtils.createFileIfNotExist(bookFolder, fileName)
val fileBytes = Base64.decode(fileData.substringAfter("base64,"), Base64.DEFAULT)
file.writeBytes(fileBytes)
val nameAuthor = LocalBook.analyzeNameAuthor(fileName)

Loading…
Cancel
Save