diff --git a/build.gradle b/build.gradle index a466dcf..84fd71e 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ repositories { maven { url "https://jitpack.io" } + jcenter() } buildscript { @@ -38,6 +39,7 @@ dependencies { compile 'org.slf4j:slf4j-api:1.7.21' compile 'ch.qos.logback:logback-classic:1.1.7' compile 'com.google.code.gson:gson:2.5' + compile 'com.github.kittinunf.fuel:fuel:1.12.0' testCompile 'junit:junit:4.12' } diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt index 6bf7425..ca60e7e 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt @@ -36,6 +36,9 @@ import com.github.badoualy.telegram.tl.api.request.TLRequestUploadGetFile import org.slf4j.LoggerFactory import org.slf4j.Logger import com.google.gson.Gson +import com.github.kittinunf.fuel.Fuel +import com.github.kittinunf.result.Result +import com.github.kittinunf.result.getAs import java.io.IOException import java.io.File @@ -502,8 +505,12 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI @Throws(IOException::class) fun downloadExternalFile(target: String, url: String): Boolean { - FileUtils.copyURLToFile(URL(url), File(target), 5000, 5000) - return true + val (_, response, result) = Fuel.get(url).response() + if (result is Result.Success) { + File(target).writeBytes(response.data) + return true + } + return false } } }