Fix regression when sharing files with spaces in the filename (#2624)
This commit is contained in:
parent
d0a4e06397
commit
67fa577695
1 changed files with 13 additions and 1 deletions
|
|
@ -9,6 +9,17 @@ import UIKit
|
|||
return Singleton.instance
|
||||
}
|
||||
|
||||
private func buildUploadURL(baseURL: String, channelId: String, fileName: String?) -> URL? {
|
||||
let urlComponent = NSURLComponents(string: "\(baseURL)/api/v4/files")
|
||||
let queryChannel = URLQueryItem(name: "channel_id", value: channelId)
|
||||
let queryFile = URLQueryItem(name: "filename", value: fileName)
|
||||
|
||||
urlComponent?.path = "/api/v4/files"
|
||||
urlComponent?.queryItems = [queryChannel, queryFile]
|
||||
print("URL TO UPLOAD \(urlComponent?.string ?? "NOT DEFINED")")
|
||||
return urlComponent?.url
|
||||
}
|
||||
|
||||
public func uploadFiles(baseURL: String, token: String, channelId: String, message: String?, attachments: AttachmentArray<AttachmentItem>, callback: () -> Void) {
|
||||
let identifier = "mattermost-share-upload-\(UUID().uuidString)"
|
||||
UploadSessionManager.shared.createUploadSessionData(
|
||||
|
|
@ -24,7 +35,8 @@ import UIKit
|
|||
|
||||
for index in 0..<attachments.count {
|
||||
guard let item = attachments[index] else {return}
|
||||
let url = URL(string: "\(baseURL)/api/v4/files?channel_id=\(channelId)&filename=\(item.fileName!)")
|
||||
|
||||
let url = buildUploadURL(baseURL: baseURL, channelId: channelId, fileName: item.fileName)
|
||||
var uploadRequest = URLRequest(url: url!)
|
||||
uploadRequest.httpMethod = "POST"
|
||||
uploadRequest.addValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
|
||||
|
|
|
|||
Loading…
Reference in a new issue