carrierwave 1.0.0.beta → 1.0.0.rc
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of carrierwave might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/carrierwave/mount.rb +8 -0
- data/lib/carrierwave/mounter.rb +5 -4
- data/lib/carrierwave/storage/file.rb +2 -1
- data/lib/carrierwave/storage/fog.rb +4 -3
- data/lib/carrierwave/uploader/download.rb +9 -4
- data/lib/carrierwave/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5c60d2300faa43e9ff11717d126919063a15cc5
|
4
|
+
data.tar.gz: 0bfec22f3441f14ad8296124d0854547e32bbe15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d5cfaedf2257a0859993eaba33054078f11ed6f0c10340ed16dde8e19811ce89c0b500994eeccaa617c1e06a192272e63a196abdcf63dce91a35a12c400eb8
|
7
|
+
data.tar.gz: 3b0861e37568ee06f45d6de233fc98e8b2f9ed93007b256b2430d086277fe50ec683ee68f11492c21fc914f6bbfd497e5d489e36cb4a95955b3495988809ec4e
|
data/README.md
CHANGED
@@ -29,13 +29,13 @@ It works well with Rack based web applications, such as Ruby on Rails.
|
|
29
29
|
Install the latest release:
|
30
30
|
|
31
31
|
```
|
32
|
-
$ gem install carrierwave -v "1.0.0.
|
32
|
+
$ gem install carrierwave -v "1.0.0.rc"
|
33
33
|
```
|
34
34
|
|
35
35
|
In Rails, add it to your Gemfile:
|
36
36
|
|
37
37
|
```ruby
|
38
|
-
gem 'carrierwave', '>= 1.0.0.
|
38
|
+
gem 'carrierwave', '>= 1.0.0.rc', '< 2.0'
|
39
39
|
```
|
40
40
|
|
41
41
|
Finally, restart the server to apply the changes.
|
@@ -745,7 +745,7 @@ the url to the file on Rackspace Cloud Files.
|
|
745
745
|
|
746
746
|
```ruby
|
747
747
|
gem "fog-google"
|
748
|
-
gem "google-api-client", "
|
748
|
+
gem "google-api-client", ">= 0.6.2", "< 0.9"
|
749
749
|
gem "mime-types"
|
750
750
|
```
|
751
751
|
|
data/lib/carrierwave/mount.rb
CHANGED
@@ -166,6 +166,10 @@ module CarrierWave
|
|
166
166
|
_mounter(:#{column}).remote_urls = [url]
|
167
167
|
end
|
168
168
|
|
169
|
+
def remote_#{column}_request_header=(header)
|
170
|
+
_mounter(:#{column}).remote_request_headers = [header]
|
171
|
+
end
|
172
|
+
|
169
173
|
def write_#{column}_identifier
|
170
174
|
return if frozen?
|
171
175
|
mounter = _mounter(:#{column})
|
@@ -316,6 +320,10 @@ module CarrierWave
|
|
316
320
|
_mounter(:#{column}).remote_urls = urls
|
317
321
|
end
|
318
322
|
|
323
|
+
def remote_#{column}_request_headers=(headers)
|
324
|
+
_mounter(:#{column}).remote_request_headers = headers
|
325
|
+
end
|
326
|
+
|
319
327
|
def write_#{column}_identifier
|
320
328
|
return if frozen?
|
321
329
|
mounter = _mounter(:#{column})
|
data/lib/carrierwave/mounter.rb
CHANGED
@@ -3,8 +3,9 @@ module CarrierWave
|
|
3
3
|
# this is an internal class, used by CarrierWave::Mount so that
|
4
4
|
# we don't pollute the model with a lot of methods.
|
5
5
|
class Mounter #:nodoc:
|
6
|
-
attr_reader :column, :record, :remote_urls, :integrity_error,
|
7
|
-
|
6
|
+
attr_reader :column, :record, :remote_urls, :integrity_error,
|
7
|
+
:processing_error, :download_error
|
8
|
+
attr_accessor :remove, :remote_request_headers
|
8
9
|
|
9
10
|
def initialize(record, column, options={})
|
10
11
|
@record = record
|
@@ -75,9 +76,9 @@ module CarrierWave
|
|
75
76
|
@download_error = nil
|
76
77
|
@integrity_error = nil
|
77
78
|
|
78
|
-
@uploaders = urls.map do |url|
|
79
|
+
@uploaders = urls.zip(remote_request_headers || []).map do |url, header|
|
79
80
|
uploader = blank_uploader
|
80
|
-
uploader.download!(url)
|
81
|
+
uploader.download!(url, header || {})
|
81
82
|
uploader
|
82
83
|
end
|
83
84
|
|
@@ -106,7 +106,8 @@ module CarrierWave
|
|
106
106
|
|
107
107
|
def clean_cache!(seconds)
|
108
108
|
Dir.glob(::File.expand_path(::File.join(uploader.cache_dir, '*'), CarrierWave.root)).each do |dir|
|
109
|
-
|
109
|
+
# generate_cache_id returns key formated TIMEINT-PID-COUNTER-RND
|
110
|
+
time = dir.scan(/(\d+)-\d+-\d+-\d+/).first.map(&:to_i)
|
110
111
|
time = Time.at(*time)
|
111
112
|
if time < (Time.now.utc - seconds)
|
112
113
|
FileUtils.rm_rf(dir)
|
@@ -136,7 +136,8 @@ module CarrierWave
|
|
136
136
|
:key => uploader.fog_directory,
|
137
137
|
:public => uploader.fog_public
|
138
138
|
).files.all(:prefix => uploader.cache_dir).each do |file|
|
139
|
-
|
139
|
+
# generate_cache_id returns key formated TIMEINT-PID-COUNTER-RND
|
140
|
+
time = file.key.scan(/(\d+)-\d+-\d+-\d+/).first.map { |t| t.to_i }
|
140
141
|
time = Time.at(*time)
|
141
142
|
file.destroy if time < (Time.now.utc - seconds)
|
142
143
|
end
|
@@ -355,8 +356,8 @@ module CarrierWave
|
|
355
356
|
end
|
356
357
|
end
|
357
358
|
when 'Google'
|
358
|
-
|
359
|
-
|
359
|
+
# https://cloud.google.com/storage/docs/access-public-data
|
360
|
+
"https://storage.googleapis.com/#{@uploader.fog_directory}/#{encoded_path}"
|
360
361
|
else
|
361
362
|
# avoid a get by just using local reference
|
362
363
|
directory.files.new(:key => path).public_url
|
@@ -10,8 +10,9 @@ module CarrierWave
|
|
10
10
|
include CarrierWave::Uploader::Cache
|
11
11
|
|
12
12
|
class RemoteFile
|
13
|
-
def initialize(uri)
|
13
|
+
def initialize(uri, remote_headers = {})
|
14
14
|
@uri = uri
|
15
|
+
@remote_headers = remote_headers
|
15
16
|
end
|
16
17
|
|
17
18
|
def original_filename
|
@@ -35,7 +36,10 @@ module CarrierWave
|
|
35
36
|
|
36
37
|
def file
|
37
38
|
if @file.blank?
|
38
|
-
|
39
|
+
headers = @remote_headers.
|
40
|
+
reverse_merge('User-Agent' => "CarrierWave/#{CarrierWave::VERSION}")
|
41
|
+
|
42
|
+
@file = Kernel.open(@uri.to_s, headers)
|
39
43
|
@file = @file.is_a?(String) ? StringIO.new(@file) : @file
|
40
44
|
end
|
41
45
|
@file
|
@@ -62,10 +66,11 @@ module CarrierWave
|
|
62
66
|
# === Parameters
|
63
67
|
#
|
64
68
|
# [url (String)] The URL where the remote file is stored
|
69
|
+
# [remote_headers (Hash)] Request headers
|
65
70
|
#
|
66
|
-
def download!(uri)
|
71
|
+
def download!(uri, remote_headers = {})
|
67
72
|
processed_uri = process_uri(uri)
|
68
|
-
file = RemoteFile.new(processed_uri)
|
73
|
+
file = RemoteFile.new(processed_uri, remote_headers)
|
69
74
|
raise CarrierWave::DownloadError, "trying to download a file which is not served over HTTP" unless file.http?
|
70
75
|
cache!(file)
|
71
76
|
end
|
data/lib/carrierwave/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|