Skip to content

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

Open
@tergel93

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions