heythisisnate-paperclip 2.3.0.2 → 2.3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/paperclip/attachment.rb +13 -5
- data/lib/paperclip/storage.rb +4 -3
- metadata +4 -4
data/lib/paperclip/attachment.rb
CHANGED
@@ -100,15 +100,23 @@ module Paperclip
|
|
100
100
|
# security, however, for performance reasons. set
|
101
101
|
# include_updated_timestamp to false if you want to stop the attachment
|
102
102
|
# update time appended to the url
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
103
|
+
def unsigned_url style = default_style, include_updated_timestamp = true
|
104
|
+
url = original_filename.nil? ? interpolate(@default_url, style) : interpolate(@url, style)
|
105
|
+
include_updated_timestamp && updated_at ? [url, updated_at].compact.join(url.include?("?") ? "&" : "?") : url
|
106
|
+
end
|
107
107
|
|
108
|
-
def
|
108
|
+
def signed_url(style = nil, time_limit = 5.seconds)
|
109
109
|
AWS::S3::S3Object.url_for(path(style).gsub(%r{^/}, ""), 'dpic', :expires_in => time_limit)
|
110
110
|
end
|
111
111
|
|
112
|
+
def url(style = nil, opts = nil)
|
113
|
+
if %w{thumb small}.include?(style.to_s)
|
114
|
+
unsigned_url style, true
|
115
|
+
else
|
116
|
+
signed_url style, 5.seconds
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
112
120
|
# Returns the path of the attachment as defined by the :path option. If the
|
113
121
|
# file is stored in the filesystem the path refers to the path of the file
|
114
122
|
# on disk. If the file is stored in S3, the path is the "key" part of the
|
data/lib/paperclip/storage.rb
CHANGED
@@ -192,10 +192,11 @@ module Paperclip
|
|
192
192
|
@queued_for_write.each do |style, file|
|
193
193
|
begin
|
194
194
|
log("saving #{path(style)}")
|
195
|
+
permissions = %{thumb small}.include?(style.to_s) ? :public_read : :authenticated_read
|
195
196
|
AWS::S3::S3Object.store(path(style),
|
196
|
-
|
197
|
-
|
198
|
-
|
197
|
+
file,
|
198
|
+
bucket_name,
|
199
|
+
{:content_type => instance_read(:content_type)}.merge({:access => permissions}).merge(@s3_headers))
|
199
200
|
rescue AWS::S3::ResponseError => e
|
200
201
|
raise
|
201
202
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heythisisnate-paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.0.
|
4
|
+
version: 2.3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Yurek
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -93,7 +93,7 @@ files:
|
|
93
93
|
- test/storage_test.rb
|
94
94
|
- test/thumbnail_test.rb
|
95
95
|
- shoulda_macros/paperclip.rb
|
96
|
-
has_rdoc:
|
96
|
+
has_rdoc: false
|
97
97
|
homepage: http://www.thoughtbot.com/projects/paperclip
|
98
98
|
licenses:
|
99
99
|
post_install_message:
|
@@ -119,7 +119,7 @@ requirements:
|
|
119
119
|
rubyforge_project: paperclip
|
120
120
|
rubygems_version: 1.3.5
|
121
121
|
signing_key:
|
122
|
-
specification_version:
|
122
|
+
specification_version: 3
|
123
123
|
summary: File attachments as attributes for ActiveRecord
|
124
124
|
test_files: []
|
125
125
|
|