You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using Alamofire 5.6.2 and trying to upload one image with POST request.
The image is 10MB size, if I upload an image around 5MB everything works fine.
Creating the POST request from Postman everything works fine, so it's not an issue related with the server.
This is how I'm creating the request:
AF.upload(multipartFormData: { multipartFormData in
multipartFormData.append(InputStream(data: imageMedia.data), // 10MB data
withLength: UInt64(imageMedia.data.count),
name: imageMedia.type.rawValue,
fileName: imageMedia.filename,
mimeType: imageMedia.mimeType)
}, with: request).responseData { afDataResponse in
switch afDataResponse.result {
case .success(let data):
completion(data)
case .failure(let error):
print("error with alamofire response: \(error.localizedDescription)")
completion(nil)
}
}
And this is the error I am receiving in the failure case: error with alamofire response: URLSessionTask failed with error: The operation couldn’t be completed. Message too long
I saw on StackOverflow that this was only a problem on the simulator, not on device? If so, this seems like an Apple change you'll want to report and investigate.
One thing you can try, though, is to ensure the upload is always streams from disk rather than entirely from memory. Currently the threshold for switching between those two approaches is exactly 10_000_000 bytes, so I don't know whether your upload is hitting it or not. You can add usingThreshold: 0 in your upload call to make sure it's entirely streamed and see if that avoids the issue.
Also, if you have a project which replicates the issue we can track whether the behavior changes over time.
I am currently using Alamofire 5.6.2 and trying to upload one image with POST request.
The image is 10MB size, if I upload an image around 5MB everything works fine.
Creating the POST request from Postman everything works fine, so it's not an issue related with the server.
This is how I'm creating the request:
And this is the error I am receiving in the failure case:
error with alamofire response: URLSessionTask failed with error: The operation couldn’t be completed. Message too long
If I print the error (not localizedDescription):
Any idea what's happening here?
The text was updated successfully, but these errors were encountered: