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

Added :use_accelerate_endpoint option when using S3 #2291

Closed
wants to merge 4 commits into from

Conversation

gagoit
Copy link
Contributor

@gagoit gagoit commented Aug 27, 2016

Amazon S3 Transfer Acceleration enables fast, easy, and secure transfers of files over long distances between your client and an S3 bucket. And aws-sdk has allowed us to enable this feature in version 2.3.0 (more detail is here).

You can now pass a configuration option (:use_accelerate_endpoint) when config Paperclip with S3. You can enable the Amazon S3 Transfer Acceleration by set this option:
:use_accelerate_endpoint => true

path: ":attachment/:basename:dotextension",
s3_host_name: "s3-accelerate.amazonaws.com",
s3_region: "ap-northeast-1",
use_accelerate_endpoint: true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of a hash literal if they span more than one line.

assert_match %r{^//s3-ap-northeast-1.amazonaws.com/bucket/avatars/data[^\.]}, @dummy.avatar.url
end

it "uses the S3 client with the use_accelerate_endpoint config is false" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [81/80]

@gagoit
Copy link
Contributor Author

gagoit commented Aug 27, 2016

Because the :use_accelerate_endpoint config is only available from aws-sdk 2.3.0, so The Travis CI build failed with my new tests (because it uses old version of aws-sdk). I am not sure what should I do now. Can somebody help me?

@tute
Copy link
Contributor

tute commented Aug 27, 2016

Can we add a condition such that that behavior is triggered both if the :use_accelerate_endpoint option is in use, and if the right version of the SDK is available? Also, if it's not the right version, we can print out a warning, or an error message.
Thanks!

@@ -152,6 +154,8 @@ def self.extended base
@options[:url] = @options[:url].inspect if @options[:url].is_a?(Symbol)

@http_proxy = @options[:http_proxy] || nil

@use_accelerate_endpoint = @options[:use_accelerate_endpoint] || false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| false is the same as nothing (falsy). We can drop that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I updated :)

path: ":attachment/:basename:dotextension",
s3_host_name: "s3-accelerate.amazonaws.com",
s3_region: "ap-northeast-1",
use_accelerate_endpoint: true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma after the last parameter of a multiline method call.

end

it "returns a url based on an :s3_host_name path" do
assert_match %r{^//s3-ap-northeast-1.amazonaws.com/bucket/avatars/data[^\.]},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [85/80]

@tute tute closed this in b55b0f2 Aug 28, 2016
@tute
Copy link
Contributor

tute commented Aug 28, 2016

Merged it in. Thank you! 🎉

@gagoit
Copy link
Contributor Author

gagoit commented Aug 29, 2016

Thanks for your updating. It's great :)

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

Successfully merging this pull request may close these issues.

None yet

3 participants