mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +00:00
Delegated downloading of external files to Fuel. This hopefully fixes #71.
This commit is contained in:
parent
8f1a9d391c
commit
004b650762
@ -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'
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user