paperclip 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of paperclip might be problematic. Click here for more details.
- data/LICENSE +1 -1
- data/NEWS +93 -54
- data/README.md +3 -3
- data/lib/paperclip.rb +1 -0
- data/lib/paperclip/attachment.rb +10 -8
- data/lib/paperclip/interpolations.rb +6 -2
- data/lib/paperclip/interpolations/plural_cache.rb +17 -0
- data/lib/paperclip/io_adapters/attachment_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/file_adapter.rb +2 -2
- data/lib/paperclip/io_adapters/stringio_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/uri_adapter.rb +1 -1
- data/lib/paperclip/storage/s3.rb +13 -7
- data/lib/paperclip/version.rb +1 -1
- data/paperclip.gemspec +2 -3
- data/test/attachment_test.rb +13 -0
- data/test/io_adapters/attachment_adapter_test.rb +25 -0
- data/test/io_adapters/file_adapter_test.rb +19 -0
- data/test/io_adapters/stringio_adapter_test.rb +11 -1
- data/test/io_adapters/uploaded_file_adapter_test.rb +23 -0
- data/test/io_adapters/uri_adapter_test.rb +16 -0
- data/test/plural_cache_test.rb +36 -0
- data/test/storage/s3_test.rb +100 -0
- metadata +126 -138
data/LICENSE
CHANGED
@@ -3,7 +3,7 @@ LICENSE
|
|
3
3
|
|
4
4
|
The MIT License
|
5
5
|
|
6
|
-
Copyright (c) 2008 Jon Yurek and thoughtbot, inc.
|
6
|
+
Copyright (c) 2008-2013 Jon Yurek and thoughtbot, inc.
|
7
7
|
|
8
8
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
9
|
of this software and associated documentation files (the "Software"), to deal
|
data/NEWS
CHANGED
@@ -1,6 +1,45 @@
|
|
1
|
+
New in 3.4.1:
|
2
|
+
|
3
|
+
* Improvement: Various documentation fixes and improvements
|
4
|
+
* Bug Fix: Clearing an attachment with `perserve_files` on should still clear the attachment
|
5
|
+
* Bug Fix: Instances are #changed? when a new file is assigned
|
6
|
+
* Bug Fix: Correctly deal with S3 styles when using a lambda
|
7
|
+
* Improvement: Accept and pass :credential_provider option to AWS-SDK
|
8
|
+
* Bug Fix: Sanitize original_filename more correctly in IO Adapters
|
9
|
+
* Improvement: s3_host_name can be a lambda
|
10
|
+
* Improvement: Cache some interpolations for speed
|
11
|
+
* Improvement: Update to latest cocaine
|
12
|
+
* Improvement: Update copyrights, various typos
|
13
|
+
|
14
|
+
New in 3.4.0:
|
15
|
+
|
16
|
+
* Bug Fix: Allow UploadedFileAdapter to force the use of `file`
|
17
|
+
* Bug Fix: Close the file handle when dealing with URIs
|
18
|
+
* Bug Fix: Ensure files are closed for writing when we're done.
|
19
|
+
* Bug Fix: Fixed 'type' being nil on Windows 7 error.
|
20
|
+
* Bug Fix: Fixed nil access when no s3 headers are defined
|
21
|
+
* Bug Fix: Fixes auto_orientation
|
22
|
+
* Bug Fix: Prevent a missing method error when switching from aws_sdk to fog
|
23
|
+
* Bug Fix: Properly fail to process invalid attachments
|
24
|
+
* Bug Fix: Server-side encryption is specified correctly
|
25
|
+
* Bug Fix: fog_public returned to true by default
|
26
|
+
* Bug Fix: Check attachment paths for duplicates, not URLs
|
27
|
+
* Feature: Add Attachment#blank?
|
28
|
+
* Feature: Add support for blacklisting certain content_types
|
29
|
+
* Feature: Add support for style-specific s3 headers and meta data
|
30
|
+
* Feature: Allow only_process to be a lambda
|
31
|
+
* Feature: Allow setting of escape url as a default option
|
32
|
+
* Feature: Create :override_file_permissions option for filesystem attachments
|
33
|
+
* Improvement: Add Attachment#as_json
|
34
|
+
* Improvement: Evaluate lambdas for fog_file properties
|
35
|
+
* Improvement: Extract geometry parsing into factories
|
36
|
+
* Improvement: Fixed various typos
|
37
|
+
* Improvement: Refactored some tests
|
38
|
+
* Improvement: Reuse S3 connections
|
39
|
+
|
1
40
|
New In 3.3.1:
|
2
41
|
|
3
|
-
* Bug
|
42
|
+
* Bug Fix: Moved Filesystem's copy_to_local_file to the right place.
|
4
43
|
|
5
44
|
New in 3.3.0:
|
6
45
|
|
@@ -8,41 +47,41 @@ New in 3.3.0:
|
|
8
47
|
|
9
48
|
New in 3.2.0:
|
10
49
|
|
11
|
-
* Bug
|
12
|
-
* Bug
|
13
|
-
* Bug
|
50
|
+
* Bug Fix: Use the new correct Amazon S3 encryption header.
|
51
|
+
* Bug Fix: The rake task respects the updated_at column.
|
52
|
+
* Bug Fix: Strip newline from content type.
|
14
53
|
* Feature: Fog file visibility can be specified per style.
|
15
54
|
* Feature: Automatically rotate images.
|
16
55
|
* Feature: Reduce class-oriented programming of the attachment definitions.
|
17
56
|
|
18
57
|
New in 3.1.4:
|
19
58
|
|
20
|
-
* Bug
|
59
|
+
* Bug Fix: Allow user to be able to set path without `:style` attribute and not raising an error.
|
21
60
|
This is a regression introduced in 3.1.3, and that feature will be postponed to another minor
|
22
61
|
release instead.
|
23
62
|
* Feature: Allow for URI Adapter as an optional paperclip io adapter.
|
24
63
|
|
25
64
|
New in 3.1.3:
|
26
65
|
|
27
|
-
* Bug
|
28
|
-
* Bug
|
29
|
-
* Bug
|
30
|
-
* Bug
|
66
|
+
* Bug Fix: Copy empty attachment between instances is now working.
|
67
|
+
* Bug Fix: Correctly rescue Fog error.
|
68
|
+
* Bug Fix: Using default path and url options in Fog storage now work as expected.
|
69
|
+
* Bug Fix: `Attachment#s3_protocol` now returns a protocol without colon suffix.
|
31
70
|
* Feature: Paperclip will now raise an error if multiple styles are defined but no `:style`
|
32
71
|
interpolation exists in `:path`.
|
33
72
|
* Feature: Add support for `#{attachment}_created_at` field
|
34
|
-
* Bug
|
35
|
-
* Bug
|
73
|
+
* Bug Fix: Paperclip now gracefully handles msising file command.
|
74
|
+
* Bug Fix: `StringIOAdapter` now accepts content type.
|
36
75
|
|
37
76
|
New in 3.1.2:
|
38
77
|
|
39
|
-
* Bug
|
78
|
+
* Bug Fix: #remove_attachment on 3.1.0 and 3.1.1 mistakenly trying to remove the column that has
|
40
79
|
the same name as data type (such as :string, :datetime, :interger.) You're advised to update to
|
41
80
|
Paperclip 3.1.2 as soon as possible.
|
42
81
|
|
43
82
|
New in 3.1.1:
|
44
83
|
|
45
|
-
* Bug
|
84
|
+
* Bug Fix: Paperclip will only load Paperclip::Schema only when Active Record is available.
|
46
85
|
|
47
86
|
New in 3.1.0:
|
48
87
|
|
@@ -64,24 +103,24 @@ New in 3.1.0:
|
|
64
103
|
* Feature: Migration now support Rails 3.2+ `change` method.
|
65
104
|
* API CHANGE: Old `t.has_attached_file` and `drop_attached_file` are now deprecated. You're advised
|
66
105
|
to update your migration file before the next MAJOR version.
|
67
|
-
* Bug
|
106
|
+
* Bug Fix: Tempfile now rewinded before generating fingerprint
|
68
107
|
* API CHANGE: Tempfiles are now unlinked after `after_flush_writes`
|
69
108
|
|
70
109
|
If you need to interact with the generated tempfiles, please define an `after_flush_writes` method
|
71
110
|
in your model. You'll be able to access files via `@queue_for_write` instance variable.
|
72
111
|
|
73
|
-
* Bug
|
74
|
-
* Bug
|
112
|
+
* Bug Fix: `:s3_protocol` can now be defined as either String or Symbol
|
113
|
+
* Bug Fix: Tempfiles are now rewinded before get passed into `after_flush_writes`
|
75
114
|
* Feature: Added expiring_url method to Fog Storage
|
76
115
|
* API CHANGE: Paperclip now tested against AWS::SDK 1.5.2 onward
|
77
|
-
* Bug
|
116
|
+
* Bug Fix: Improved the output of the content_type validator so the actual failure is displayed
|
78
117
|
* Feature: Animated formats now identified using ImageMagick.
|
79
118
|
* Feature: AttachmentAdapter now support fetching attachment with specific style.
|
80
119
|
* Feature: Paperclip default options can now be configured in Rails.configuration.
|
81
120
|
* Feature: add Geometry#resize_to to calculate dimensions of new source.
|
82
|
-
* Bug
|
121
|
+
* Bug Fix: Fixed a bug whereby a file type with multiple mime types but no official type would cause
|
83
122
|
the best_content_type to throw an error on trying nil.content_type.
|
84
|
-
* Bug
|
123
|
+
* Bug Fix: Fix problem when the gem cannot be installed on the system that has Asepsis installed.
|
85
124
|
|
86
125
|
New in 3.0.4:
|
87
126
|
|
@@ -89,14 +128,14 @@ New in 3.0.4:
|
|
89
128
|
|
90
129
|
New in 3.0.3:
|
91
130
|
|
92
|
-
* Bug
|
93
|
-
* Bug
|
94
|
-
* Bug
|
131
|
+
* Bug Fix: ThumbnailProcessor now correctly detects and preserve animated GIF.
|
132
|
+
* Bug Fix: File extension is now preserved in generated Tempfile from adapter.
|
133
|
+
* Bug Fix: Uploading file with unicode file name now won't raise an error when
|
95
134
|
logging in the AWS is turned on.
|
96
|
-
* Bug
|
97
|
-
* Bug
|
98
|
-
* Bug
|
99
|
-
* Bug
|
135
|
+
* Bug Fix: Task "paperclip:refresh:missing_styles" now work correctly.
|
136
|
+
* Bug Fix: Handle the case when :restricted_characters is nil.
|
137
|
+
* Bug Fix: Don't delete all the existing styles if we reprocess.
|
138
|
+
* Bug Fix: Content type is now ensured to not having a new line character.
|
100
139
|
* API CHANGE: Non-Rails usage should include Paperclip::Glue directly.
|
101
140
|
|
102
141
|
`Paperclip::Railtie` was intended to be used with Ruby on Rails only. If you're
|
@@ -105,24 +144,24 @@ New in 3.0.3:
|
|
105
144
|
|
106
145
|
ActiveRecord::Base.send :include, Paperclip::Glue
|
107
146
|
|
108
|
-
* Bug
|
109
|
-
* Bug
|
110
|
-
* Bug
|
111
|
-
* Bug
|
147
|
+
* Bug Fix: AttachmentContentTypeValidator now allow you to specify :allow_blank/:allow_nil
|
148
|
+
* Bug Fix: Make sure content type always a String.
|
149
|
+
* Bug Fix: Fix attachment.reprocess! when using storage providers fog and s3.
|
150
|
+
* Bug Fix: Fix a problem with incorrect content_type detected with 'file' command for an empty file on Mac.
|
112
151
|
|
113
152
|
New in 3.0.2:
|
114
153
|
|
115
154
|
* API CHANGE: Generated migration class name is now plural (AddAttachmentToUsers instead of AddAttachmentToUser)
|
116
155
|
* API CHANGE: Remove Rails plugin initialization code.
|
117
156
|
* API CHANGE: Explicitly require Ruby 1.9.2 in the Gemfile.
|
118
|
-
* Bug
|
119
|
-
* Bug
|
120
|
-
* Bug
|
157
|
+
* Bug Fix: Fixes AWS::S3::Errors::RequestTimeout on Model#save.
|
158
|
+
* Bug Fix: Fix a problem when there's no logger specified.
|
159
|
+
* Bug Fix: Fix a problem when attaching Rack::Test::UploadedFile instance.
|
121
160
|
|
122
161
|
New in 3.0.1:
|
123
162
|
|
124
163
|
* Feature: Introduce Paperlip IO adapter.
|
125
|
-
* Bug
|
164
|
+
* Bug Fix: Regression in AttachmentContentTypeValidator has been fixed.
|
126
165
|
* API CHANGE: #to_file has been removed. Use the #copy_to_local_file method instead.
|
127
166
|
|
128
167
|
New in 3.0.0:
|
@@ -139,29 +178,29 @@ New in 3.0.0:
|
|
139
178
|
:url => "/system/:attachment/:id/:style/:filename"
|
140
179
|
|
141
180
|
* Feature: Adding Rails 3 style validators, and adding `validates_attachment` method as a shorthand.
|
142
|
-
* Bug
|
143
|
-
* Bug
|
144
|
-
* Bug
|
181
|
+
* Bug Fix: Paperclip's rake tasks now loading records in batch.
|
182
|
+
* Bug Fix: Attachment style name with leading number now not raising an error.
|
183
|
+
* Bug Fix: File given to S3 and Fog storage will now be rewinded after flush_write.
|
145
184
|
* Feature: You can now pass addional parameter to S3 expiring URL, such as :content_type.
|
146
185
|
|
147
186
|
New in 2.7.0:
|
148
187
|
|
149
|
-
* Bug
|
150
|
-
* Bug
|
151
|
-
* Bug
|
188
|
+
* Bug Fix: Checking the existence of a file on S3 handles all AWS errors.
|
189
|
+
* Bug Fix: Clear the fingerprint when removing an attachment.
|
190
|
+
* Bug Fix: Attachment size validation message reads more nicely now.
|
152
191
|
* Feature: Style names can be either symbols or strings.
|
153
192
|
* Compatibility: Support for ActiveSupport < 2.3.12.
|
154
193
|
* Compatibility: Support for Rails 3.2.
|
155
194
|
|
156
195
|
New in 2.6.0:
|
157
196
|
|
158
|
-
* Bug
|
197
|
+
* Bug Fix: Files are re-wound after reading.
|
159
198
|
* Feature: Remove Rails dependency from specs that need Paperclip.
|
160
199
|
* Feature: Validation matchers support conditionals.
|
161
200
|
|
162
201
|
New in 2.5.2:
|
163
202
|
|
164
|
-
* Bug
|
203
|
+
* Bug Fix: Can be installed on Windows.
|
165
204
|
* Feature: The Fog bucket name, authentication, and host can be determined at runtime via Proc.
|
166
205
|
* Feature: Special characters are replaced with underscores in #url and #path.
|
167
206
|
|
@@ -174,23 +213,23 @@ New in 2.5.1:
|
|
174
213
|
New in 2.5.0:
|
175
214
|
|
176
215
|
* Performance: Only connect to S3 when absolutely needed.
|
177
|
-
* Bug
|
178
|
-
* Bug
|
216
|
+
* Bug Fix: STI with cached classes respect new options.
|
217
|
+
* Bug Fix: conditional validations broke, and now work again.
|
179
218
|
* Feature: URL generation is now parameterized and can be changed with plugins or custom code.
|
180
219
|
* Feature: :convert_options and :source_file_options to control the ImageMagick processing.
|
181
220
|
* Performance: String geometry specifications now parse more quickly.
|
182
|
-
* Bug
|
183
|
-
* Bug
|
184
|
-
* Bug
|
221
|
+
* Bug Fix: Handle files with question marks in the filename.
|
222
|
+
* Bug Fix: Don't raise an error when generating an expiring URL on an unassigned attachment.
|
223
|
+
* Bug Fix: The rake task runs over all instances of an ActiveRecord model, ignoring default scopes.
|
185
224
|
* Feature: DB migration has_attached_file and drop_attached_file methods.
|
186
|
-
* Bug
|
187
|
-
* Bug
|
188
|
-
* Bug
|
225
|
+
* Bug Fix: Switch from AWS::S3 to AWS::SDK for the S3 backend.
|
226
|
+
* Bug Fix: URL generator uses '?' in the URL unless it already appears and there is no prior '='.
|
227
|
+
* Bug Fix: Always convert the content type to a string before stripping blanks.
|
189
228
|
* Feature: The :keep_old_files option preserves the files in storage even when the attachment is cleared or changed.
|
190
229
|
* Performance: Optimize Fog's public_url access by avoiding it when possible.
|
191
|
-
* Bug
|
230
|
+
* Bug Fix: Avoid a runtime error when generating the ID partition for an unsaved attachment.
|
192
231
|
* Performance: Do not calculate the fingerprint if it is never persisted.
|
193
|
-
* Bug
|
232
|
+
* Bug Fix: Process the :original style before all others, in case of a dependency.
|
194
233
|
* Feature: S3 headers can be set at runtime by passing a proc object as the value.
|
195
|
-
* Bug
|
196
|
-
* Bug
|
234
|
+
* Bug Fix: Generating missing attachment styles for a model which has had its attachment changed should not raise.
|
235
|
+
* Bug Fix: Do not collide with the built-in Ruby hashing method.
|
data/README.md
CHANGED
@@ -101,7 +101,7 @@ In your model:
|
|
101
101
|
```ruby
|
102
102
|
class User < ActiveRecord::Base
|
103
103
|
attr_accessible :avatar
|
104
|
-
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
|
104
|
+
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
|
105
105
|
end
|
106
106
|
```
|
107
107
|
|
@@ -615,7 +615,7 @@ Please see `CONTRIBUTING.md` for more details on contributing and running test.
|
|
615
615
|
Credits
|
616
616
|
-------
|
617
617
|
|
618
|
-
![thoughtbot](http://thoughtbot.com/
|
618
|
+
![thoughtbot](http://thoughtbot.com/logo.png)
|
619
619
|
|
620
620
|
Paperclip is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
|
621
621
|
|
@@ -626,5 +626,5 @@ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
|
626
626
|
License
|
627
627
|
-------
|
628
628
|
|
629
|
-
Paperclip is Copyright © 2008-
|
629
|
+
Paperclip is Copyright © 2008-2013 thoughtbot, inc. It is free software, and may be
|
630
630
|
redistributed under the terms specified in the MIT-LICENSE file.
|
data/lib/paperclip.rb
CHANGED
@@ -35,6 +35,7 @@ require 'paperclip/geometry'
|
|
35
35
|
require 'paperclip/processor'
|
36
36
|
require 'paperclip/tempfile'
|
37
37
|
require 'paperclip/thumbnail'
|
38
|
+
require 'paperclip/interpolations/plural_cache'
|
38
39
|
require 'paperclip/interpolations'
|
39
40
|
require 'paperclip/tempfile_factory'
|
40
41
|
require 'paperclip/style'
|
data/lib/paperclip/attachment.rb
CHANGED
@@ -110,6 +110,8 @@ module Paperclip
|
|
110
110
|
# Reset the file size if the original file was reprocessed.
|
111
111
|
instance_write(:file_size, @queued_for_write[:original].size)
|
112
112
|
instance_write(:fingerprint, @queued_for_write[:original].fingerprint) if instance_respond_to?(:fingerprint)
|
113
|
+
updater = :"#{name}_file_name_will_change!"
|
114
|
+
instance.send updater if instance.respond_to? updater
|
113
115
|
end
|
114
116
|
|
115
117
|
# Returns the public URL of the attachment with a given style. This does
|
@@ -231,10 +233,8 @@ module Paperclip
|
|
231
233
|
# nil to the attachment *and saving*. This is permanent. If you wish to
|
232
234
|
# wipe out the existing attachment but not save, use #clear.
|
233
235
|
def destroy
|
234
|
-
|
235
|
-
|
236
|
-
save
|
237
|
-
end
|
236
|
+
clear
|
237
|
+
save
|
238
238
|
end
|
239
239
|
|
240
240
|
# Returns the uploaded file if present.
|
@@ -452,10 +452,12 @@ module Paperclip
|
|
452
452
|
end
|
453
453
|
|
454
454
|
def queue_all_for_delete #:nodoc:
|
455
|
-
return if
|
456
|
-
@
|
457
|
-
|
458
|
-
|
455
|
+
return if !file?
|
456
|
+
unless @options[:preserve_files]
|
457
|
+
@queued_for_delete += [:original, *styles.keys].uniq.map do |style|
|
458
|
+
path(style) if exists?(style)
|
459
|
+
end.compact
|
460
|
+
end
|
459
461
|
instance_write(:file_name, nil)
|
460
462
|
instance_write(:content_type, nil)
|
461
463
|
instance_write(:file_size, nil)
|
@@ -36,6 +36,10 @@ module Paperclip
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def self.plural_cache
|
40
|
+
@plural_cache ||= PluralCache.new
|
41
|
+
end
|
42
|
+
|
39
43
|
# Returns the filename, the same way as ":basename.:extension" would.
|
40
44
|
def filename attachment, style_name
|
41
45
|
[ basename(attachment, style_name), extension(attachment, style_name) ].reject(&:blank?).join(".")
|
@@ -81,7 +85,7 @@ module Paperclip
|
|
81
85
|
# all class names. Calling #class will return the expected class.
|
82
86
|
def class attachment = nil, style_name = nil
|
83
87
|
return super() if attachment.nil? && style_name.nil?
|
84
|
-
attachment.instance.class.to_s
|
88
|
+
plural_cache.underscore_and_pluralize(attachment.instance.class.to_s)
|
85
89
|
end
|
86
90
|
|
87
91
|
# Returns the basename of the file. e.g. "file" for "file.jpg"
|
@@ -169,7 +173,7 @@ module Paperclip
|
|
169
173
|
# Returns the pluralized form of the attachment name. e.g.
|
170
174
|
# "avatars" for an attachment of :avatar
|
171
175
|
def attachment attachment, style_name
|
172
|
-
attachment.name.to_s.downcase
|
176
|
+
plural_cache.pluralize(attachment.name.to_s.downcase)
|
173
177
|
end
|
174
178
|
|
175
179
|
# Returns the style, or the default style if nil is supplied.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Paperclip
|
2
|
+
module Interpolations
|
3
|
+
class PluralCache
|
4
|
+
def initialize
|
5
|
+
@cache = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def pluralize(word)
|
9
|
+
@cache[word] ||= word.pluralize
|
10
|
+
end
|
11
|
+
|
12
|
+
def underscore_and_pluralize(word)
|
13
|
+
@cache[word] ||= word.underscore.pluralize
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -14,7 +14,7 @@ module Paperclip
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def cache_current_values
|
17
|
-
|
17
|
+
self.original_filename = @target.original_filename
|
18
18
|
@content_type = @target.content_type
|
19
19
|
@tempfile = copy_to_tempfile(@target)
|
20
20
|
@size = @tempfile.size || @target.size
|
@@ -8,8 +8,8 @@ module Paperclip
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def cache_current_values
|
11
|
-
|
12
|
-
|
11
|
+
self.original_filename = @target.original_filename if @target.respond_to?(:original_filename)
|
12
|
+
self.original_filename ||= File.basename(@target.path)
|
13
13
|
@tempfile = copy_to_tempfile(@target)
|
14
14
|
@content_type = ContentTypeDetector.new(@target.path).detect
|
15
15
|
@size = File.size(@target)
|
@@ -13,7 +13,7 @@ module Paperclip
|
|
13
13
|
def cache_current_values
|
14
14
|
@original_filename = @target.original_filename if @target.respond_to?(:original_filename)
|
15
15
|
@original_filename ||= "stringio.txt"
|
16
|
-
|
16
|
+
self.original_filename = @original_filename.strip
|
17
17
|
|
18
18
|
@content_type = @target.content_type if @target.respond_to?(:content_type)
|
19
19
|
@content_type ||= "text/plain"
|
@@ -20,7 +20,7 @@ module Paperclip
|
|
20
20
|
def cache_current_values
|
21
21
|
@original_filename = @target.path.split("/").last
|
22
22
|
@original_filename ||= "index.html"
|
23
|
-
|
23
|
+
self.original_filename = @original_filename.strip
|
24
24
|
|
25
25
|
@content_type = @content.content_type if @content.respond_to?(:content_type)
|
26
26
|
@content_type ||= "text/html"
|
data/lib/paperclip/storage/s3.rb
CHANGED
@@ -172,7 +172,10 @@ module Paperclip
|
|
172
172
|
end
|
173
173
|
|
174
174
|
def s3_host_name
|
175
|
-
@options[:s3_host_name]
|
175
|
+
host_name = @options[:s3_host_name]
|
176
|
+
host_name = host_name.call(self) if host_name.is_a?(Proc)
|
177
|
+
|
178
|
+
host_name || s3_credentials[:s3_host_name] || "s3.amazonaws.com"
|
176
179
|
end
|
177
180
|
|
178
181
|
def s3_host_alias
|
@@ -209,7 +212,7 @@ module Paperclip
|
|
209
212
|
config[:proxy_uri] = URI::HTTP.build(proxy_opts)
|
210
213
|
end
|
211
214
|
|
212
|
-
[:access_key_id, :secret_access_key].each do |opt|
|
215
|
+
[:access_key_id, :secret_access_key, :credential_provider].each do |opt|
|
213
216
|
config[opt] = s3_credentials[opt] if s3_credentials[opt]
|
214
217
|
end
|
215
218
|
|
@@ -307,10 +310,11 @@ module Paperclip
|
|
307
310
|
write_options[:server_side_encryption] = @s3_server_side_encryption
|
308
311
|
end
|
309
312
|
|
310
|
-
style_specific_options =
|
311
|
-
|
312
|
-
|
313
|
-
|
313
|
+
style_specific_options = styles[style]
|
314
|
+
|
315
|
+
if style_specific_options
|
316
|
+
merge_s3_headers( style_specific_options[:s3_headers], @s3_headers, @s3_metadata) if style_specific_options[:s3_headers]
|
317
|
+
@s3_metadata.merge!(style_specific_options[:s3_metadata]) if style_specific_options[:s3_metadata]
|
314
318
|
end
|
315
319
|
|
316
320
|
write_options[:metadata] = @s3_metadata unless @s3_metadata.empty?
|
@@ -363,8 +367,10 @@ module Paperclip
|
|
363
367
|
YAML::load(ERB.new(File.read(creds)).result)
|
364
368
|
when Hash
|
365
369
|
creds
|
370
|
+
when NilClass
|
371
|
+
{}
|
366
372
|
else
|
367
|
-
raise ArgumentError, "Credentials are not a path, file, proc, or hash."
|
373
|
+
raise ArgumentError, "Credentials given are not a path, file, proc, or hash."
|
368
374
|
end
|
369
375
|
end
|
370
376
|
|