【发布时间】:2015-01-20 08:58:10
【问题描述】:
我的代码出现以下奇怪错误。 NSFilemanager 中的文件路径有限制吗?真正奇怪的是,通过 AWS S3 上传时,这条路径可以正常工作
AWSURLSessionManager URLSession:dataTask:didReceiveResponse:completionHandler:] |错误:无法使用文件路径创建文件:/profilePicture12.jpeg
AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithAccessKey:AWS_Access_Key secretKey:AWS_Secret_Key];
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSWest1 credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
self.downloadRequest = [AWSS3TransferManagerDownloadRequest new];
//bucket and image name
self.downloadRequest.bucket = AWS_Bucket_Name;
self.downloadRequest.key = S3_Link;
//unique customer path to store download
NSString* uniqueCustomerPath = [NSString stringWithFormat:@"profilePicture%ld.jpeg", (long)self.current_customer.id];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:uniqueCustomerPath];
self.downloadRequest.downloadingFileURL = [NSURL fileURLWithPath:uniqueCustomerPath];
AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
[[transferManager download:self.downloadRequest] continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(BFTask *task){
if (task.error != nil) {
NSLog(@"Error: [%@]", task.error);}
else {
///do stuff
}
return nil;
}];
【问题讨论】:
标签: ios amazon-s3 nsfilemanager