title: AWS S3 Upload - Using AccessKey, SecretKey and SessionToken - iOS SDK
body: <p>I am working on iOS Application, where i need to upload the images in to AWS S3Bucket. I have got the temporary credential(accessKey,secretKey, sessionToken and bucketName) from the server to upload the images.</p>
  
  <p>I am finding it difficult to identify the correct API to use this credential to upload the images.</p>
  
  <p>AWS sample program is given using AWSCognitoCredentialsProvider.</p>
  
  <p>I have got the working Android version of code to upload the images in to S3. But i could not find the corresponding APIs in iOS SDK. </p>
  
  <pre><code> BasicSessionCredentials basiccredentials = new BasicSessionCredentials(
                              MY_ACCESS_KEY_ID, MY_SECRET_KEY,
                              MY_SESSION_TOKEN);
  AmazonS3Client s3Client = new AmazonS3Client(
                              basiccredentials);
  TransferManager manager = new TransferManager(s3Client);
  PutObjectRequest por = new PutObjectRequest(Constants.getPictureBucket(), Constants.PICTURE_NAME,file name);
   manager.upload(por);
  </code></pre>
  
  <p>iOS SDK has the following CredentialsProvider classes</p>
  
  <ol>
  <li>AWSCognitoCredentialsProvider</li>
  <li>AWSStaticCredentialsProvider</li>
  <li>AWSWebIdentityCredentialsProvider</li>
  </ol>
  
  <p><strong>AWSStaticCredentialsProvider</strong> class accepts only <strong>accessKey</strong> and <strong>secretKey</strong>. Other 2 classes expects different parameters.</p>
  
  <p>When i use AWSStaticCredentialsProvider with accessKey and secretKey to upload the images, i am getting the following error message</p>
  
  <blockquote>
    <p>Upload failed: [Error Domain=NSURLErrorDomain Code=-1017 "cannot parse
    response" UserInfo=0x7f8773f70ee0 {NSUnderlyingError=0x7f8773f4bbb0
    "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error
    -1017.)", NSErrorFailingURLStringKey=<a href="https://s3.amazonaws.com/playfiksprofilepictures/429bfd812ea08e706bab868f3cd8b9c6.jpg" rel="nofollow">https://s3.amazonaws.com/playfiksprofilepictures/429bfd812ea08e706bab868f3cd8b9c6.jpg</a>,
    NSErrorFailingURLKey=<a href="https://s3.amazonaws.com/playfiksprofilepictures/429bfd812ea08e706bab868f3cd8b9c6.jpg" rel="nofollow">https://s3.amazonaws.com/playfiksprofilepictures/429bfd812ea08e706bab868f3cd8b9c6.jpg</a>,
    _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-1, NSLocalizedDescription=cannot parse response}]</p>
  </blockquote>
  
  <p>This error message is not clear whether the issue with the credential Provider or something else</p>
  
  <p>Any help is highly appreciated to resolve this issue</p>
  
  <p>Thank you</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have used the sample program provided by @user3467204</p>
  
  <p>Here is the output with the error message(The AWS Access Key Id you provided does not exist in our records). But with the same key, android java code works fine.</p>
  
  <p>Android code uses accessKey,secrectKey and sessionToken, but iOS code uses only accessKey and secrectKey.  </p>
  
  <blockquote>
    <p>2015-06-01 19:42:55.747 AWSV2Test[2191:170157] Image is at /Users/jpsasi/Library/Developer/CoreSimulator/Devices/E846AC10-82BE-40AA-BB7E-29796A8FAD2B/data/Containers/Bundle/Application/B59E9032-306D-4609-97D6-6C516638463A/AWSV2Test.app/testimage.png
    2015-06-01 19:42:56.841 AWSV2Test[2191:170157] Uploaded 32677 / 35516 bytes
    2015-06-01 19:42:56.842 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:42:56.843 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:43:00.249 AWSV2Test[2191:170157] Uploaded 32677 / 35516 bytes
    2015-06-01 19:43:00.250 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:43:00.251 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:43:02.848 AWSV2Test[2191:170157] Uploaded 32677 / 35516 bytes
    2015-06-01 19:43:02.849 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:43:02.850 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:43:05.285 AWSV2Test[2191:170157] Uploaded 32677 / 35516 bytes
    2015-06-01 19:43:05.286 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:43:05.287 AWSV2Test[2191:170157] Uploaded 35516 / 35516 bytes
    2015-06-01 19:43:06.681 AWSV2Test[2191:170157] error => Error Domain=com.amazonaws.AWSS3ErrorDomain Code=3 "The operation couldn’t be completed. (com.amazonaws.AWSS3ErrorDomain error 3.)" UserInfo=0x7faea40171d0 {HostId=GeMapgMjrv43TZ4yFKmTjIw6EsZafbgk3GH9ATtbgIj1VpNNv6EjhmZhobHVm+/2, Message=The AWS Access Key Id you provided does not exist in our records., AWSAccessKeyId=ASIAIFYM7NXH3CSNXY3Q, Code=InvalidAccessKeyId, RequestId=653371138733BE48}</p>
  </blockquote>