thoughtbot/paperclip — pull request #1147 by marceldegraaf (2013-01-25 13:14:33+00:00)
Title: Add support for passing a session_token option to S3 credentials

This pull request adds the possibility to pass a session_token option to the S3 credentials of a Paperclip model. This allows you to use S3 authentication based on an IAM Instance Role instead of a configuration file, like this:

```
class MyModel
has_attached_file :avatar, :s3_credentials => Proc.new { MyModel.s3_credentials }

def self.s3_credentials
AWS::Core::CredentialProviders::EC2Provider.new.credentials
end
end
```

In this case the resulting Hash from self.s3_credentials contains an access_key_id, secret_access_key and a session_token. This session_token is crucial; without it authentication to S3 fails.

There was a previous pull request to add this functionality [here](https://github.com/thoughtbot/paperclip/pull/692) but that was closed due to missing tests.
I would love to add some useful tests for this but I can't quite figure out how to properly test this. If one of the maintainers could give me a pointer I'd be happy to implement the tests.