title: Amazon S3 uploadPart returning null
body: <p>I am trying to use Amazon S3 SDK to upload a large file in parts to S3 server. I have the following code:</p>
  
  <pre><code>-(void)multipartUpload:(NSData*)dataToUpload inBucket:(NSString*)bucket forKey:(NSString*)key
  {
      //bool using3G = ![self isWifiAvailable];
  
      AmazonS3Client *s3 = [[AmazonS3Client alloc] initWithAccessKey:kS3ApplicationKey withSecretKey:kS3ApplicationSecret];
  
      s3.timeout = 99999999;
  
      @try {
          //[s3 createBucketWithName:bucket];
  
          S3InitiateMultipartUploadRequest *initReq = [[S3InitiateMultipartUploadRequest alloc] initWithKey:key inBucket:bucket];
          S3MultipartUpload *upload = [s3 initiateMultipartUpload:initReq].multipartUpload;
          S3CompleteMultipartUploadRequest *compReq = [[S3CompleteMultipartUploadRequest alloc] initWithMultipartUpload:upload];
  
          int numberOfParts = [self countParts:dataToUpload];
  
  
          for ( int part = 0; part &lt; numberOfParts; part++ ) {
              NSLog(@"%d", part);
  
              NSData *dataForPart = [self getPart:part fromData:dataToUpload];
  
              // The S3UploadInputStream was deprecated after the release of iOS6.
              NSInputStream *stream = [NSInputStream inputStreamWithData:dataForPart];
  
              S3UploadPartRequest *upReq = [[S3UploadPartRequest alloc] initWithMultipartUpload:upload];
              upReq.partNumber = ( part + 1 );
              upReq.contentLength = [dataForPart length];
              upReq.stream = stream;
              upReq.delegate = self;
  
              S3UploadPartResponse *response = [s3 uploadPart:upReq]; // &lt;----- null returned here :(
              [compReq addPartWithPartNumber:( part + 1 ) withETag:response.etag];
          }
  
          [s3 completeMultipartUpload:compReq];
      }
      @catch ( AmazonServiceException *exception ) {
          NSLog( @"Multipart Upload Failed, Reason: %@", exception  );
      }
      @catch (NSException *exception) {
          NSLog( @"Other exception %@", exception);
      }
  }
  </code></pre>
  
  <p>The problem is that uploadPart method is returning null instead of actual server response which leads to an exception at the next line.</p>
  
  <p>I have implemented all delegate methods to check for errors, but there is nothing reported.</p>
  
  <p>The code is copied from here: <a href="http://aws.amazon.com/articles/0006282245644577" rel="nofollow">http://aws.amazon.com/articles/0006282245644577</a></p>
  
  <p>Any ideas why is it not working? </p>