Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Request failed: forbidden (403) while using putObjectWithFile #102

Open
bobongski opened this issue Oct 29, 2015 · 2 comments
Open

Request failed: forbidden (403) while using putObjectWithFile #102

bobongski opened this issue Oct 29, 2015 · 2 comments

Comments

@bobongski
Copy link

AFAmazonS3Manager *s3Manager = [[AFAmazonS3Manager alloc] initWithAccessKeyID:@"123" secret:@"123"];
s3Manager.requestSerializer.region = AFAmazonS3USStandardRegion;
s3Manager.requestSerializer.bucket = @"test-bucket";

// 2
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"imagetest" ofType:@"jpg"];
NSLog(@"filePath %@",filePath);
// 3
NSString *destinationPath = @"dummy.jpg";

[s3Manager putObjectWithFile:filePath destinationPath:@"destinationPath" parameters:nil progress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {

} success:^(id responseObject) {
    //   NSURL *resultURL = [self.requestSerializer.endpointURL URLByAppendingPathComponent:destinationPath];

    NSLog(@"Upload complete : %@", responseObject);
} failure:^(NSError *error) {
    NSLog(@"Error uploading photo : %@", error);
}];
@masuhara
Copy link

I have the same issue when I upload to S3 buckets. 403 forbidden.
Even though I used "postObject...", I have same issue.

AFAmazonS3Manager *s3Manager = [[AFAmazonS3Manager alloc] initWithAccessKeyID:@"XXX" secret:@"XXX"];
s3Manager.requestSerializer.region = AFAmazonS3APNortheast2Region;
s3Manager.requestSerializer.bucket = @"XXXXX";
[s3Manager.requestSerializer setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"];
NSString *destinationPath = @"movie.mov";

[s3Manager putObjectWithFile:self.session.outputURL.path destinationPath:destinationPath parameters:nil progress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
    NSLog(@"%f%% Uploaded", (totalBytesWritten / (totalBytesExpectedToWrite * 1.0f) * 100));
}success:^(AFAmazonS3ResponseObject *responseObject) {
    NSLog(@"Upload Complete: %@", responseObject.URL);
}failure:^(NSError *error) {
    NSLog(@"Error: %@", error);
}];

@msanders
Copy link

@masuhara @bobongski Were you able to resolve this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants