- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我收到 NSURLErrorDomain Code=-1021“请求正文流耗尽”
NSLocalizedDescription=请求体流耗尽,NSUnderlyingError=0x2088c080“请求体流耗尽”
上传多张大尺寸图片时出现此错误我正在使用 AFNetworking 并尝试在线搜索修复程序,但未成功
NSDictionary *clientUniqueId = [NSDictionary dictionaryWithObject:NSLocalizedString(uniqueDrId, nil) forKey:@"clientUniqueId"];
NSMutableURLRequest *request = [client multipartFormRequestWithMethod:@"POST"
path:pendingUpload.urlPath
parameters:clientUniqueId
constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
{
[formData appendPartWithFormData:[pendingUpload dataRecordData] name:@"dr"];
NSArray *attachments = pendingUpload.attachments;
if (attachments != nil) {
for (Attachment *attachment in attachments) {
[formData appendPartWithFileData:attachment.data
name:attachment.key
fileName:attachment.filename
mimeType:attachment.contentType];
}
}
}];
最佳答案
如 AFNetworking FAQ 中所述:
Why are some upload requests failing with the error "request body stream exhausted"? What does that mean, and how do I fix this?
When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Using
-throttleBandwidthWithPacketSize:delay:
your multipart form construction block, you can set a maximum packet size and delay according to the recommended values (kAFUploadStream3GSuggestedPacketSize
andkAFUploadStream3GSuggestedDelay
). This lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
关于ios - 域=NSURLError域代码=-1021 "request body stream exhausted",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16068158/
我想检查是否发生了NSURLErrorCancelled。所以基本上映射this SO answer到 C#。 我唯一想到的就是直接检查错误代码: if(e.Error.Code != -999){
考虑这段代码: func load(url: URL?, callback: ((UIImage?) -> Void)? = nil) -> UIImage? { guard let url
我正在开发一个应用程序,我在其中使用网络服务方法从服务器获取数据。 下面是我的代码。 responseData = [NSMutableData data]; NSString *servic
当我从服务器收到 401 响应时,错误代码为 -6003。我需要捕获它并做点什么。而不是 switch error.code { case -6003: // TODO: } 我想要更多 sw
我是一名优秀的程序员,十分优秀!