trying to upload the file from iPhone iCloud to the multipart API. When the file name is in English text it shows well after uploading but I do have the file name in another language than English then it is wrong.
在下图中,文件名是中文“ sample .pdf”,但是当我上传它时,作为响应,我得到的文本是“??.pdf”
后端 API 已经处理了这种转换,因为当我从 Android 上传文件时它可以正常工作。
此外,当我从 textfiled 发送文本时,它会正确显示我应该为字符串做什么?
//上传API调用代码
myRequestData.append("\(MPboundary)\r\n".data(using: String.Encoding.utf8)!)
// set upload image, name is the key of image
myRequestData.append("Content-Disposition: form-data; name=\"\(mediaObj!.key)\"; filename=\"\(mediaObj!.fileName)\"\r\n".data(using: String.Encoding.utf8)!)
myRequestData.append("Content-Type: \(mediaObj!.mimeType)\r\n\r\n".data(using: String.Encoding.utf8)!)
myRequestData.append(mediaObj!.data!)
myRequestData.append("\r\n".data(using: String.Encoding.utf8)!)
最佳答案
请将 db filename
字段 collation
更改为 utf8mb4_unicode_ci
它将被修复,否则您必须在发送 时对其进行编码文件名
并在您的应用程序上显示时对其进行解码。
关于ios - 在 Swift 4.2 中传递给多部分 API 的非拉丁(多语言)文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58875450/