Ios amazon s3中的多部分上载未调用委托
我使用多部分上传文件上传它的工作。但是,不呼叫代表如何呼叫代表 这是我的代码:Ios amazon s3中的多部分上载未调用委托,ios,objective-c,amazon-s3,Ios,Objective C,Amazon S3,我使用多部分上传文件上传它的工作。但是,不呼叫代表如何呼叫代表 这是我的代码: AmazonS3Client *s31 = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY]; s31.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2]; s31.timeout = 240;
AmazonS3Client *s31 = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY];
s31.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2];
s31.timeout = 240;
@try
{
[s31 createBucketWithName:bucket];
S3InitiateMultipartUploadRequest *initReq = [[S3InitiateMultipartUploadRequest alloc] initWithKey:key inBucket:bucket];
S3MultipartUpload *upload = [s31 initiateMultipartUpload:initReq].multipartUpload;
S3CompleteMultipartUploadRequest *compReq = [[S3CompleteMultipartUploadRequest alloc] initWithMultipartUpload:upload];
int numberOfParts = [self countParts:imageData];
for ( int part = 0; part < numberOfParts; part++ ) {
NSData *dataForPart = [self getPart:part fromData:imageData];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[appDelegate.dataArray addObject:dataForPart];
// The S3UploadInputStream was deprecated after the release of iOS6.
NSInputStream *stream = [NSInputStream inputStreamWithData:dataForPart];
//if ( using3G ) {
// If connected via 3G "throttle" the stream.
//stream.delay = 0.2; // In seconds
//stream.packetSize = 16; // Number of 1K blocks
// }
S3UploadPartRequest *upReq = [[S3UploadPartRequest alloc] initWithMultipartUpload:upload];
upReq.partNumber = ( part + 1 );
upReq.contentLength = [dataForPart length];
upReq.stream = stream;
S3UploadPartResponse *response = [s31 uploadPart:upReq];
[compReq addPartWithPartNumber:( part + 1 ) withETag:response.etag];
NSLog(@"Coming222");
}
[s31 completeMultipartUpload:compReq];
[self textfileupload];
}
@catch ( AmazonServiceException *exception )
{
isUpload=NO;
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
NSLog( @"Multipart Upload Failed, Reason: %@", exception );
}
AmazonS3Client*s31=[[AmazonS3Client alloc]initWithAccessKey:ACCESS\u KEY\u ID with secretkey:SECRET\u KEY];
s31.endpoint=[Amazondpoints s3Endpoint:US_WEST_2];
s31.0超时=240;
@试一试
{
[s31 createBucketWithName:bucket];
S3InitiateMultipartUploadRequest*initReq=[[S3InitiateMultipartUploadRequest alloc]initWithKey:key inBucket:bucket];
S3multipartPload*upload=[s31 initiateMultipartUpload:initReq].multipartPload;
S3CompleteMultipPartUploadRequest*compReq=[[S3CompleteMultipPartUploadRequest alloc]initWithMultipartPload:upload];
int numberOfParts=[self countParts:imageData];
对于(int part=0;part
请帮助我。如果希望它调用委托方法,则需要执行此操作,就像对依赖委托方法的任何对象执行此操作一样:
putObjectRequest.delegate = self;
[putObjectRequest setDelegate:self];
如果您指的是如何使用AppDelegate实例:AppDelegate*AppDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate]代码>,然后仔细检查类型转换为AppDelegate指针是否正确。也许可以尝试另一种初始化/分配方法,因为我在依赖类型转换为cocoa指针的返回对象时遇到了问题