Skip to content

Commit

Permalink
Limit size of binary image to 1 million bytes. It prevents the SQLite…
Browse files Browse the repository at this point in the history
…BlobTooBigException that would happen when downloading big images.

Fixes #94
  • Loading branch information
Benoit Vermont authored and cortinico committed Aug 16, 2019
1 parent 73a6b28 commit 71a5036
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import okhttp3.Response
import okio.Buffer
import okio.BufferedSource

private const val MAX_BLOB_SIZE = 1000_000L

/**
* An OkHttp Interceptor which persists and displays HTTP activity
* in your application for later inspection.
Expand Down Expand Up @@ -126,7 +128,7 @@ class ChuckerInterceptor @JvmOverloads constructor(
} else {
transaction.isResponseBodyPlainText = false

if (transaction.responseContentType?.contains("image") == true) {
if (transaction.responseContentType?.contains("image") == true && buffer.size() < MAX_BLOB_SIZE) {
transaction.responseImageData = buffer.clone().readByteArray()
}
}
Expand Down

0 comments on commit 71a5036

Please sign in to comment.