effective_assets 1.9.4 → 1.9.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20a77f1197fa8a7ccf0c56518e305fb23fa09625
|
4
|
+
data.tar.gz: 37aec983b5f2e971ab49f1bc15eb0df9d588f169
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d3b68cc22b7ae95feef14210b22bfe52f732d680e269129f05338db191125594549dca1bed2ef70063b027245e2e50792ff5d0f18597529b5d2e132b993da6
|
7
|
+
data.tar.gz: 46b1685339f2f3ea8d5f33106e29542c8318e7bb1504cdfddf456dac855954e72e390c6890167b8c43e511033c60316c10e1b6b33d91721b45828e03a1a42bd5
|
@@ -157,7 +157,7 @@ module Effective
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def file_name
|
160
|
-
upload_file.to_s.split('/').last rescue upload_file
|
160
|
+
upload_file.to_s.split('/').last.gsub(/\?.+/, '') rescue upload_file
|
161
161
|
end
|
162
162
|
|
163
163
|
def video?
|
@@ -205,7 +205,7 @@ module Effective
|
|
205
205
|
self.remote_data_url = url
|
206
206
|
else
|
207
207
|
puts 'Non S3 Asset downloading and processing'
|
208
|
-
puts
|
208
|
+
puts "Downloading #{upload_file}"
|
209
209
|
|
210
210
|
self.remote_data_url = upload_file
|
211
211
|
end
|
@@ -235,7 +235,7 @@ module Effective
|
|
235
235
|
|
236
236
|
def set_content_type
|
237
237
|
if [nil, 'null', 'unknown', 'application/octet-stream', ''].include?(content_type)
|
238
|
-
self.content_type = case File.extname(file_name
|
238
|
+
self.content_type = case File.extname(file_name.to_s.downcase.gsub(/\?.+/, ''))
|
239
239
|
when '.mp3' ; 'audio/mp3'
|
240
240
|
when '.mp4' ; 'video/mp4'
|
241
241
|
when '.mov' ; 'video/mov'
|
data/config/effective_assets.rb
CHANGED
@@ -29,7 +29,7 @@ EffectiveAssets.setup do |config|
|
|
29
29
|
config.aws_bucket = '' # ENV.fetch('AWS_S3_BUCKET')
|
30
30
|
config.aws_access_key_id = '' # ENV.fetch('AWS_ACCESS_KEY_ID')
|
31
31
|
config.aws_secret_access_key = '' # ENV.fetch('AWS_SECRET_ACCESS_KEY')
|
32
|
-
config.aws_region = 'us-east-1'
|
32
|
+
config.aws_region = 'us-east-1' # ENV.fetch('AWS_REGION') # ca-central-1
|
33
33
|
|
34
34
|
config.aws_path = 'assets/'
|
35
35
|
|
@@ -93,4 +93,37 @@ namespace :effective_assets do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
desc 'Download all'
|
97
|
+
task :download, [:start_at, :end_at, :version] => :environment do |t, args|
|
98
|
+
args.with_defaults(start_at: 1, end_at: Effective::Asset.unscoped.maximum(:id), version: nil)
|
99
|
+
args.version.gsub!(':', '') if args.version
|
100
|
+
ids = Range.new(args.start_at.to_i, args.end_at.to_i)
|
101
|
+
|
102
|
+
Dir.mkdir('downloads') unless File.exist?('downloads')
|
103
|
+
|
104
|
+
Effective::Asset.where(id: ids).find_each do |asset|
|
105
|
+
(GC.start rescue nil)
|
106
|
+
|
107
|
+
Dir.mkdir("downloads/#{asset.id}") unless File.exist?("downloads/#{asset.id}")
|
108
|
+
|
109
|
+
# This goes through all versions, and nil, the original file
|
110
|
+
([nil] + Array(asset.data.try(:versions).try(:keys))).each do |version|
|
111
|
+
next unless (args.version.nil? || args.version == version.to_s)
|
112
|
+
|
113
|
+
url = URI(asset.url(version))
|
114
|
+
file_name = asset.public_url(version).to_s.split('/').last
|
115
|
+
|
116
|
+
begin
|
117
|
+
puts "downloading #{asset.id}/#{file_name}"
|
118
|
+
|
119
|
+
File.open("downloads/#{asset.id}/#{file_name}", 'wb') do |file|
|
120
|
+
file.write(open(url.to_s).read)
|
121
|
+
end
|
122
|
+
rescue => e
|
123
|
+
puts "ERROR: unable to download #{asset.id}/#{file_name} (#{url})"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
96
129
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|