Ios 从服务器检索文件内容';s响应流并写入文件
我使用以下代码从服务器获取数据:Ios 从服务器检索文件内容';s响应流并写入文件,ios,objective-c,Ios,Objective C,我使用以下代码从服务器获取数据: AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject){} failure:^(AFHTTPRequestOperation *operation, NSError *error){}]; o
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request
success:^(AFHTTPRequestOperation *operation, id responseObject){}
failure:^(AFHTTPRequestOperation *operation, NSError *error){}];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:
[DOCUMENTS_FOLDER stringByAppendingPathComponent:@"test.m4v"] append:YES];
问题是:服务器发送了512 KB的数据,但写入的数据超过900 KB。我认为原因是:它将每个字节的十六进制表示形式写入文件,而不是二进制文件
请帮助:如何写入二进制数据?它是否可以正常工作而不是大小?在
Accept Encoding
HTTP请求头中发送什么?我猜它会将每个字节作为字符串写入文件。这就是文件大小大于预期的原因。@trojanfoe:我不发送接受编码。在我的案例中,这是问题的原因吗?是的,我认为您需要更多地关注HTTP协议,告诉服务器您可以接受什么,并检查响应头以查看它发送给您的内容。