1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-10 04:52:38 +01:00

Check extension after successful response

This commit is contained in:
Allan Wang 2019-09-08 01:46:30 -07:00
parent 926d0a6e92
commit ed9dfdd76d
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56

View File

@ -362,12 +362,12 @@ class ImageActivity : KauBaseActivity() {
.call()
.execute()
imgExtension = getImageExtension(response.header("Content-Type")) ?: ".jpg"
if (!response.isSuccessful) {
throw IOException("Unsuccessful response for image: ${response.peekBody(128).string()}")
}
imgExtension = getImageExtension(response.header("Content-Type")) ?: ".jpg"
val body = response.body() ?: throw IOException("Failed to retrieve image body")
file.copyFromInputStream(body.byteStream())