quick_file 1.0.4 → 1.2.0
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/quick_file.rb +19 -1
- data/lib/quick_file/upload.rb +15 -1
- data/lib/quick_file/version.rb +1 -1
- metadata +3 -3
data/lib/quick_file.rb
CHANGED
@@ -31,7 +31,7 @@ module QuickFile
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def is_video_file?(filename)
|
34
|
-
filename.downcase.end_with?('.mov', '.3gp', '.wmv', '.m4v', '.mp4')
|
34
|
+
filename.downcase.end_with?('.mov', '.3gp', '.wmv', '.m4v', '.mp4', '.flv')
|
35
35
|
end
|
36
36
|
|
37
37
|
def fog_connection
|
@@ -73,6 +73,24 @@ module QuickFile
|
|
73
73
|
outfile
|
74
74
|
end
|
75
75
|
|
76
|
+
def convert_video_to_mp4(file)
|
77
|
+
new_file = QuickFile.new_cache_file(".mp4")
|
78
|
+
`ffmpeg -i #{file} -vcodec libx264 -b 500k -bt 50k -acodec libfaac -ab 56k -ac 2 -s 480x320 #{new_file}`
|
79
|
+
new_file
|
80
|
+
end
|
81
|
+
|
82
|
+
def convert_video_to_flv(file)
|
83
|
+
new_file = QuickFile.new_cache_file(".flv")
|
84
|
+
`ffmpeg -i #{file} -f flv -ar 11025 -r 24 -s 480x320 #{new_file}`
|
85
|
+
new_file
|
86
|
+
end
|
87
|
+
|
88
|
+
def create_video_thumb(file)
|
89
|
+
new_file = QuickFile.new_cache_file(".jpg")
|
90
|
+
`ffmpeg -i #{file} #{new_file}`
|
91
|
+
new_file
|
92
|
+
end
|
93
|
+
|
76
94
|
def cache_path(cn)
|
77
95
|
File.join(CACHE_DIR, cn)
|
78
96
|
end
|
data/lib/quick_file/upload.rb
CHANGED
@@ -11,6 +11,7 @@ module QuickFile
|
|
11
11
|
# 3. store
|
12
12
|
|
13
13
|
STATES = {:loaded => 0, :cached => 1, :processing => 2, :processed => 3, :storing => 4, :stored => 5, :deleted => 6, :error => 7}
|
14
|
+
FILE_CATEGORIES = {:none => 0, :image => 1, :video => 2, :file => 3}
|
14
15
|
|
15
16
|
included do
|
16
17
|
cattr_accessor :processes
|
@@ -261,15 +262,28 @@ module QuickFile
|
|
261
262
|
"#{proto}#{QuickFile.host_url[storage_type.to_sym]}#{styles[style_name]["path"]}"
|
262
263
|
end
|
263
264
|
|
264
|
-
def
|
265
|
+
def delete_files
|
265
266
|
# delete uploaded files
|
266
267
|
styles.each do |k,v|
|
267
268
|
QuickFile.fog_directory.files.new(:key => v["path"]).destroy if v["path"]
|
268
269
|
File.delete(v["cache"]) if (v["cache"] && File.exists?(v["cache"]))
|
269
270
|
end
|
270
271
|
self.state = STATES[:deleted]
|
272
|
+
save
|
271
273
|
end
|
272
274
|
|
275
|
+
def file_category
|
276
|
+
if self.state.nil?
|
277
|
+
return FILE_CATEGORIES[:none]
|
278
|
+
elsif self.is_image?
|
279
|
+
return FILE_CATEGORIES[:image]
|
280
|
+
elsif self.is_video?
|
281
|
+
return FILE_CATEGORIES[:video]
|
282
|
+
else
|
283
|
+
return FILE_CATEGORIES[:file]
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
273
287
|
def url_hash
|
274
288
|
ret = {}
|
275
289
|
processes.keys.each do |style_name|
|
data/lib/quick_file/version.rb
CHANGED
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 2
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.4
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alan Graham
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-07-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rmagick
|