Skip to content

Commit

Permalink
fix: deprecation errors following OkHttp upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
edeckers committed Jan 17, 2022
1 parent 9ab7437 commit 78b3c8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ class BlobSender(

val response = sendRequestCall.execute()

val responseBody = response.body()?.string().orEmpty()
val responseBody = response.body?.string().orEmpty()

li("Finished unmanaged send")

return Success(
mapOf(
"response" to mapOf(
"code" to response.code(),
"code" to response.code,
"data" to if (senderParameters.returnResponse) responseBody else "",
"headers" to mapHeadersToMap(response.headers())
"headers" to mapHeadersToMap(response.headers)
)
)
)
} catch (e: IOException) {
if (sendRequestCall.isCanceled) {
if (sendRequestCall.isCanceled()) {
return Failure(createErrorFromThrowable(ERROR_CANCELED_EXCEPTION, e))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ import io.deckers.blob_courier.common.maybe
import io.deckers.blob_courier.common.right
import io.deckers.blob_courier.common.testKeep
import io.deckers.blob_courier.common.validationContext
import io.deckers.blob_courier.upload.FilePayload
import io.deckers.blob_courier.upload.StringPayload
import io.deckers.blob_courier.upload.UploaderParameters
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import java.net.URL

Expand All @@ -61,8 +58,8 @@ data class SenderParameters(

fun SenderParameters.toRequestBody(contentResolver: ContentResolver): RequestBody =
InputStreamRequestBody(
mediaType.let(MediaType::parse)
?: MediaType.get(DEFAULT_MIME_TYPE),
mediaType.toMediaTypeOrNull()
?: DEFAULT_MIME_TYPE.toMediaType(),
contentResolver,
absoluteFilePath
)
Expand Down

0 comments on commit 78b3c8b

Please sign in to comment.