gpt4 book ai didi

ios - 域=NSURLError域代码=-1021 "request body stream exhausted"

转载 作者:可可西里 更新时间:2023-11-01 06:25:00 25 4
gpt4 key购买 nike

我收到 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 and kAFUploadStream3GSuggestedDelay). 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com