Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.