Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contentType:text/html; charset=windows-1251 when upload photos to the user's wall #546

Open
tergel93 opened this issue Dec 4, 2023 · 0 comments

Comments

@tergel93
Copy link

tergel93 commented Dec 4, 2023

I'm testing photo uploading function in v4.1.0.

  1. retrieve upload url
fun getServerUploadInfo() : VKServerUploadInfo {
  val response = VK.executeSync(
    PhotosService().photosGetWallUploadServer(null)
  )
  return VKServerUploadInfo(response)
}
  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant