Created
December 21, 2018 12:33
-
-
Save enginebai/118b79f90809804d1e8383b48420af0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileUploadWorker(context: Context, params: WorkerParameters) : Woker(context, params) { | |
override fun doWork(): Result { | |
return try { | |
val response = ... // send PUT /message/media reequest | |
when (uploadResponse.code() / 100) { | |
2 -> Result.SUCCESS | |
4 -> Result.FAILURE | |
else -> Result.RETRY | |
} | |
} catch (e: FileNotFoundException) { | |
Result.FAILURE | |
} catch (e: IOException) { | |
Result.RETRY | |
} finally { | |
... // close resources | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment