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

putObjectWithFile Authorization problem #82

Open
oldshuren opened this issue Mar 5, 2015 · 3 comments
Open

putObjectWithFile Authorization problem #82

oldshuren opened this issue Mar 5, 2015 · 3 comments

Comments

@oldshuren
Copy link

If I use putObjectWithFile with some x-amz headers, for example

x-amz-acl: public-read

The Authorization header is calculated wrong. Because x-amz-acl is not included in the calculation. Another header missing from the calculation is Content-Type.

Here is another question. If I want to putObject with NSData, it seems that I have write my own method.

Thanks!

@oldshuren
Copy link
Author

The problem is in setObjectWithMethod, the Authorization is calculated before parameters added to the request. But if I pass parameters to requestWithMethod, they'll just be ignored and Content-Type become s "application/x-www-form-urlencoded" :(

@chrisallick
Copy link

To fix the content-type problem I modified AFURLRequestSerialization.m. I added

[self setValue:@"image/png" forHTTPHeaderField:@"Content-Type"];

@parkerdonat
Copy link

@chrisallick,I have a content type issue as well. Where in the AFURLRequestSerialization.m file should I apply that?

In AFURLRequestSerialization.m, I added your code in this if statement:

if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
[mutalbleRequest setValue:@"image/jpeg" forHTTPHeaderField:@"Content-Type"];
}

This appears to work. Each file now is opened with my preferred content type.

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