How does the Genesys Cloud Web Messaging SDK handle file upload validation on the client side before the POST request is even attempted? I’m building a custom Android chat UI in Kotlin using the genesys-cloud-messaging-widget SDK, and I need to restrict users from uploading anything larger than 5MB or formats other than image/jpeg, image/png, and application/pdf. The default widget seems to have these limits hardcoded, but since I’m bypassing the UI and calling the API directly via the SDK’s sendFileMessage method, I’m hitting a 400 Bad Request with a generic INVALID_FILE_TYPE error when I try to send a .exe file for testing.
I’ve been digging through the SDK source, and it looks like the validation happens server-side after the multipart form data is constructed. Here’s the snippet I’m using to trigger the upload:
val file = File(cacheDir, "test_image.png")
val uri = Uri.fromFile(file)
messagingClient.sendFileMessage(
sessionId = activeSession.id,
fileUri = uri,
fileName = "test_image.png",
mimeType = "image/png"
).enqueue(object : Callback<SendFileResponse> {
override fun onResponse(call: Call<SendFileResponse>, response: Response<SendFileResponse>) {
if (response.isSuccessful) {
Log.d("Chat", "File sent successfully")
} else {
Log.e("Chat", "Upload failed: ${response.errorBody()?.string()}")
}
}
override fun onFailure(call: Call<SendFileResponse>, t: Throwable) {
Log.e("Chat", "Network error", t)
}
})
The error response body doesn’t give me much to work with, just a JSON object with {"code": "invalid_file_type", "message": "File type not allowed"}. I don’t want to rely on the server rejecting the request because that wastes bandwidth and gives a bad UX on slow connections. Is there a way to hook into the SDK’s internal validation logic, or do I need to write my own pre-check in Kotlin using MimeTypeMap and File.length() before calling sendFileMessage? Also, are the size limits configurable via the POST /api/v2/conversations/messaging/sessions/{sessionId}/messages endpoint, or are they strictly enforced by the platform settings in the admin portal? I can’t find a clear API doc that lists the exact byte limits for each MIME type category.