pushfile 0.0.2 → 0.1.0

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: 672a79ecf90538535f66127795c40bfc277ce9d2
4
- data.tar.gz: 186e1726fc0884f7986d0314133039a967e7c07c
3
+ metadata.gz: 08dd069e3ed633b00723ff573b347a12a4ec013c
4
+ data.tar.gz: 57b936ba1c94284fb8c3840b62f94497bdfc2ed8
5
5
  SHA512:
6
- metadata.gz: 6bb10f4c496d31fee90cdae4c186bacd3b67cd707e047797fb84fc642c11e5d9901e37c3f5651d13dc87c980a790326820945d05da9b9424a0768a15fff3471f
7
- data.tar.gz: 1c0532d6422f9bc7d53f05efa2082db6a3d967b1bb4d03f0b29599b939fd98f7b81797413f73294d5eadb29d50174ab9cd206d59a0b2a52290a931f66818f37e
6
+ metadata.gz: c1240765b5250ec9965b96f56681bfc85f9bc110e368c8bcd78ed66b43017430480df1e3bf9723a0c9e536e469bc93fb492c208fefa6657a83ac1dfe971b0bc0
7
+ data.tar.gz: 621a21483ec85a6b993d92a4ae51da33729b6c6f47ad8ae7f36f47bc45d1a4e0cae8219387a7b79304815cf0b4f5a106990aef318b4b87f9c3bc93793ab4d577
@@ -1,4 +1,9 @@
1
1
  **Version 0.0.2** - *2017-01-05*
2
2
 
3
+ - Added support for datafile params (dropzone.js)
4
+ - Fixed a merge option issue
5
+
6
+ **Version 0.0.2** - *2017-01-05*
7
+
3
8
  - Default mime type if not set
4
9
  - Symbols instead of string
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Pushfile Cloud File Uploader
2
- Upload files to Rackspace Cloud or Amazon S3 by URL or file with automatic image resizing.
2
+ Upload files to Rackspace Cloud or Amazon S3 by URL or file, with automatic image resizing and thumbnails.
3
3
 
4
4
  ### Installation
5
5
  ```
@@ -25,7 +25,7 @@ Create a config/pushfile.yml for your settings.
25
25
 
26
26
  See [the example pushfile.yml](https://github.com/fugroup/pushfile/blob/master/config/pushfile.yml) for an example.
27
27
 
28
- If you define an image config, any images you upload will be automatically resized before uploading. You can define both the desired max height and width.
28
+ If you define an image config, any images you upload will be automatically resized before uploading. You can define both the desired max height and width. All images will also be thumbnailed.
29
29
 
30
30
  ### Usage
31
31
  For more examples have a look at [the tests for Pushfile.](https://github.com/fugroup/pushfile/blob/master/test/upload_test.rb)
@@ -52,6 +52,21 @@ u.create
52
52
  # Get uploaded url with data
53
53
  u.status # => Hash with urls and data
54
54
 
55
+ # Example response hash
56
+ {
57
+ # The file URL
58
+ :url => "http://f.7i.no/1484109810_fugroup_avatar.jpg",
59
+
60
+ # The thumbnail URL (only for images)
61
+ :thumb_url => "http://f.7i.no/1484109810_fugroup_avatar_thumb.jpg",
62
+
63
+ # The size of the file after resizing
64
+ :size => 40288,
65
+
66
+ # The file's mime type
67
+ :mimetype => "image/jpeg"
68
+ }
69
+
55
70
  # Remove file from CDN
56
71
  u.destroy(url)
57
72
  ```
@@ -13,9 +13,9 @@ module Pushfile
13
13
  elsif @options[:filename]
14
14
  ajax_upload
15
15
 
16
- # Do the froala file uploads
17
- elsif @options[:file]
18
- froala_upload
16
+ # Do Froala or Dropzone file uploads
17
+ elsif @options[:file] || @options[:datafile]
18
+ file_upload
19
19
 
20
20
  end
21
21
  end
@@ -39,11 +39,11 @@ module Pushfile
39
39
  {:filename => filename, :tempfile => File.new(file), :type => type}
40
40
  end
41
41
 
42
- # Froala upload
43
- def froala_upload
44
- tmpfile = @options[:file][:tempfile]
45
- filename = @options[:file][:filename]
46
- type = @options[:file][:type] || mimetype(filename)
42
+ # File upload
43
+ def file_upload
44
+ o = @options[:file] || @options[:datafile]
45
+ tmpfile, filename = o[:tempfile], o[:filename]
46
+ type = o[:type] || mimetype(filename)
47
47
 
48
48
  {:filename => filename, :tempfile => tmpfile, :type => type}
49
49
  end
@@ -8,8 +8,6 @@ module Pushfile
8
8
  begin
9
9
  image = MiniMagick::Image.open(@file.path)
10
10
  image.resize("#{@width}x#{@height}")
11
- rescue MiniMagick::Invalid
12
- # Skip if file type can't be resized
13
11
  rescue
14
12
  # Pass on any error
15
13
  else
@@ -22,18 +20,11 @@ module Pushfile
22
20
  begin
23
21
  image = MiniMagick::Image.open(@file.path)
24
22
  image.resize("#{Pushfile.settings[:images][:thumb][:width]}x")
25
- rescue MiniMagick::Invalid
26
- # Skip if file type can't be resized
27
- @thumb = nil
28
- Mailer.new.system_message("#{@file.path} #{@file.size}", "Can't resize").deliver rescue nil
29
23
  rescue
30
24
  @thumb = nil
31
- Mailer.new.system_message("#{@file.path} #{@file.size}", "File not found or something else").deliver rescue nil
32
25
  else
33
- t = @name.split('.')
34
- ext = t.pop
26
+ t = @name.split('.'); ext = t.pop
35
27
  @thumb = t.join(".").concat("_thumb.#{ext}")
36
-
37
28
  image.write("/tmp/#{@thumb}") rescue @thumb = nil
38
29
  end
39
30
  end
@@ -25,11 +25,11 @@ module Pushfile
25
25
  :container => send("#{@provider}_container"),
26
26
  :max => Pushfile.settings[:upload_limit],
27
27
  :snet => Pushfile.mode == 'production',
28
- :provider => @provider,
28
+ :provider => @provider
29
29
  }.merge(o)
30
30
 
31
31
  # Merge image config
32
- o.merge!(Pushfile.settings[:images][config]) rescue nil
32
+ o = Pushfile.settings[:images][config].merge(o) rescue o
33
33
 
34
34
  # Storing options
35
35
  @options = o
@@ -50,18 +50,11 @@ module Pushfile
50
50
 
51
51
  # Create upload
52
52
  def create
53
- if @data.is_a?(String)
54
- @file = File.open(@data)
55
- @name = filename(@data)
56
- else
57
- @file = @data[:tempfile]
58
- @name = filename(@data[:filename])
59
- end
53
+ @file = @data.is_a?(String) ? File.open(@data) : @data[:tempfile]
54
+ @name = filename(@data.is_a?(String) ? @data : @data[:filename])
60
55
 
61
56
  # Check if it's more than max or return error
62
- if @max and @file.size > @max
63
- return (@status = {:error => 'upload_file_size_is_too_big'})
64
- end
57
+ return (@status = {:error => 'upload_file_size_is_too_big'}) if @max and @file.size > @max
65
58
 
66
59
  # Resize file and create thumbnail for image
67
60
  if @name =~ IMAGE_REGEX
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'pushfile'
3
- s.version = '0.0.2'
4
- s.date = '2017-01-11'
3
+ s.version = '0.1.0'
4
+ s.date = '2017-01-22'
5
5
  s.summary = "Pushfile Cloud File Uploader"
6
6
  s.description = "Upload files to Rackspace Cloud or Amazon S3 by URL or file with automatic image resizing."
7
7
  s.authors = ["Fugroup Limited"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-11 00:00:00.000000000 Z
11
+ date: 2017-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport