contentType:text/html; charset=windows-1251 when upload photos to the user's wall #546
Open
Description
I'm testing photo uploading function in v4.1.0.
- retrieve upload url
fun getServerUploadInfo() : VKServerUploadInfo {
val response = VK.executeSync(
PhotosService().photosGetWallUploadServer(null)
)
return VKServerUploadInfo(response)
}
- upload photo
fun uploadPhoto() {
VKHttpPostCall.Builder()
.url(serverUploadInfo.uploadUrl)
.args("photo", uri, "image.jpg")
.timeout(TimeUnit.MINUTES.toMillis(5))
.retryCount(RETRY_COUNT)
.build()
val fileUploadInfo = manager.execute(fileUploadCall, null, FileUploadInfoParser())
}
SDK throws JsonException in FileUploadInfoParser. I noticed that the response json object is nested in a structure like {"root_response":"{}"}.
Then I debugged the code and found out it was due to the upload URL responds with "contentType:text/html; charset=windows-1251", and there's no typeConverter handled such contentType, so VKSDK ran into the fallback logic in ResponseBodyJsonConverter
:
return jsonResponse ?: JSONObject().apply {
put(FALLBACK_RESPONSE_KEY, responseBodyStream.readString())
}
I'm wondering if I should modify the FileUploadInfoParser to handle the new JSON format, or it's just a photo service bug
Metadata
Assignees
Labels
No labels