我正在尝试将文件上传到服务器,例如在App Store中存在的Citrix fileSharing。
使用Url Schemes我能够在长时间按下文件时将我的应用程序显示为打开并将其复制到应用程序
如何在“打开方式”后将文件复制到我的应用程序后上传文件?
NSString *urlString =[NSString stringWithFormat:@"https://suremdm1jobs.s3.amazonaws.com/1210001/File%20Store/Shared/?X-Amz-Expires=126000&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIUWYTLGYBHPCWTNQ/20170426/us-east-1/s3/aws4_request&X-Amz-Date=20170426T060015Z&X-Amz-SignedHeaders=host&X-Amz-Signature=65b1dda18a96136d1bedd7c6da9bc8529b737370bb42f3328f24399763f48fbc"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"PUT"];
[request addValue:@"7919" forHTTPHeaderField: @"Content-Length"];
[request addValue:@"application/json" forHTTPHeaderField: @"Content-Type"];
[request addValue:@"bytes 0-7918/7919" forHTTPHeaderField: @"Content-Range"];
NSMutableData *putData = [NSMutableData data];
[putData appendData:[NSData dataWithData:data]];
// Append
[request setHTTPBody:putData];
NSError *err;
NSURLResponse *response;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSString *resSrt = [[NSString alloc]initWithData:responseData encoding:NSASCIIStringEncoding];
我做错了什么。我总是收到不支持的Url错误(-1002)。
答案 0 :(得分:0)
使用它:
将AFURLSessionManager *uploadSession
配置为defaultSessionConfiguration
。
使用上面的方法#2设置NSMutableURLRequest
。
使用AFNetworking的uploadTaskWithStreamedRequest:progress:completionHandler
:
Bottomline: backgroundSessionConfiguration
无法使用流式多部分表单,我无法获得uploadTaskWithRequest:fromFile:
中包含的其他数据。