Reputation: 2828
AWSS3TransferUtilityErrorDomain Code=2
getting this error when uploading reaches 100% on iOS while android is working fine.
I am using react-native-s3
. but it seems to be an issue with sdk or my bucket policy but I don't know how to fix this.
More info: To upload, I am using CognitoCredentials, the region, IdentityPool, and sessionToken generated from our server.
EDIT: This only happens on iOS. Android is working fine.
Upvotes: 2
Views: 5253
Reputation: 1
In my case, i have config all region but i forget to set headerRequest and parameterRequest after i set its work for me
expression.setValue("public-read-write", forRequestHeader: "x-amz-acl") expression.setValue("public-read-write", forRequestParameter: "x-amz-acl")
Upvotes: 0
Reputation: 968
In my case, the case for the issue was special symbols in the file name, in particular %
. Filtering special symbols from the file name before uploading the file solved the issue.
Upvotes: 0
Reputation: 5876
Check your ARN at the time of adding policy to S3 bucket. It should be like
arn:aws:s3:::yourBucketName/*
if you are uploading in your bucket directly without any sub directory.
Upvotes: 1
Reputation: 188
I know this is an old question, however it's better to write my situation and solution. In my iOS (Swift) project, I was trying to upload a picture after login (using Cognito) and I got this error:
Error Domain=com.amazonaws.AWSS3TransferUtilityErrorDomain Code=2 "(null)"
Everything seemed well on code below:
transferUtility.uploadData(
data,
key: "my-picture.png",
contentType: "image/png",
expression: expression,
completionHandler: completionHandler).continueWith { (task) -> AnyObject? in
if let error = task.error {
print("Error: \(error.localizedDescription)")
DispatchQueue.main.async {
print("Error on upload: \(error.localizedDescription)")
}
}
if let _ = task.result {
DispatchQueue.main.async {
print("Upload Starting!")
}
}
return nil;
}
The solution is on AWS Amplify Storage documentation. As stated there, I should have written the key value like key: "private/{user_identity_id}/my-picture.png"
Maybe, it will help anybody in the future.
Upvotes: 0
Reputation: 2828
So it seems my problem was wrong region. I don't know why Android works though.
Upvotes: 2
Reputation: 155
Typically this is an S3 bucket policy issue, permissions. Below is an example policy script for s3.
<key>AWS</key>
<dict>
<key>CredentialsProvider</key>
<dict>
<key>CognitoIdentity</key>
<dict>
<key>Default</key>
<dict>
<key>PoolId</key>
<string>us-west-2:xxxxx</string>
<key>Region</key>
<string>USWest2</string>
</dict>
</dict>
</dict>
<key>S3TransferUtility</key>
<dict>
<key>Default</key>
<dict>
<key>Region</key>
<string>**USEast1**</string>
</dict>
</dict>
</dict>
Upvotes: 1