Skip to content
This repository was archived by the owner on Jan 28, 2019. It is now read-only.

Commit f07b7cf

Browse files
committed
Fix issue where Slack returns upload_error when using webAPI.uploadFile()
1 parent 461de5e commit f07b7cf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/NetworkInterface.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,14 @@ public struct NetworkInterface {
134134
let boundaryEnd = "--\(boundaryConstant)--\r\n"
135135
let contentDispositionString = "Content-Disposition: form-data; name=\"file\"; filename=\"\(filename)\"\r\n"
136136
let contentTypeString = "Content-Type: \(filetype)\r\n\r\n"
137+
let dataEnd = "\r\n"
137138

138139
guard
139140
let boundaryStartData = boundaryStart.data(using: .utf8),
140141
let dispositionData = contentDispositionString.data(using: .utf8),
141142
let contentTypeData = contentTypeString.data(using: .utf8),
142-
let boundaryEndData = boundaryEnd.data(using: .utf8)
143+
let boundaryEndData = boundaryEnd.data(using: .utf8),
144+
let dataEndData = dataEnd.data(using: .utf8)
143145
else {
144146
errorClosure(SlackError.clientNetworkError)
145147
return
@@ -150,6 +152,7 @@ public struct NetworkInterface {
150152
requestBodyData.append(contentsOf: dispositionData)
151153
requestBodyData.append(contentsOf: contentTypeData)
152154
requestBodyData.append(contentsOf: data)
155+
requestBodyData.append(contentsOf: dataEndData)
153156
requestBodyData.append(contentsOf: boundaryEndData)
154157

155158
request.setValue(contentType, forHTTPHeaderField: "Content-Type")

0 commit comments

Comments
 (0)