Custom send file message

Hello, I’ve encountered the following issue when sending a file message with custom data in params. So, my aim is to be able to send audio files, m4a format, and setting a specific value to customType field. Previously we’ve been sending the files just by passing the file url to the sendDocumentFileMessage method, which was working fine and the returned file URL was decoded successfully as an m4a file.
Unfortunately, when building the message params myself, the upload works fine, but the returnded URL is no longer m4a (at least the url path). I thought that maybe my implementation missed something so I’ve checked the implementation here and did pretty much the same stuff as for send document files.

Below is my code:

   func sendAudioMessage(with url: URL) {
     guard let data = try? Data(contentsOf: url),
           let mimeType = SBUUtils.getMimeType(url: url),
           let params = SBDFileMessageParams(file: data) else { return }
     params.fileName = "Audio message"
     params.fileSize = UInt(data.count)
     params.customType = "AUDIO_MESSAGE"
     params.mimeType = mimeType
     sendFileMessage(messageParams: params)

I am wondering what I might be missing, because if I just send it using the sendDocumentFile method it works fine (but I need to be able to set custom params to the message before sending it)

UIKit version: [v2.1.12]



After further investigation, I’ve found out that the issue was setting the fileName field without the file mimeType extension, so once I’ve added .m4a it started working.

Hello @sergiu.ncy ,

Sorry for the late confirmation. I’m glad the problem is solved.
I will add the contents to our document referring to your case!
Thank you for sharing the solution! :grinning: :pray: