carrierwave-viewer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,6 +20,10 @@ Add groupdocs_guid column to your mounted model:
20
20
 
21
21
  add_column :uploads, :groupdocs_guid, :string
22
22
 
23
+ Optionally, you can store document thumbnails as it comes from GroupDocs in binary format (for displaying using Data URI technique):
24
+
25
+ add_column :uploads, :groupdocs_thumbnail, :text
26
+
23
27
  ## Usage
24
28
 
25
29
  CarrierWave.configure do |config|
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Viewer
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -3,14 +3,20 @@ module CarrierWave
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- after :store, :save_to_groupdocs
6
+ SUPPORTED_TYPES = ['application/pdf', 'application/msword', 'application/vnd.ms-powerpoint']
7
+ after :cache, :save_to_groupdocs
7
8
  end
8
9
 
9
10
  private
10
11
 
11
12
  def save_to_groupdocs(file)
12
- groupdocs_file = GroupDocs::Storage::File.upload!(file.path, {}, client_id: self.groupdocs_client_id, private_key: self.groupdocs_private_key)
13
- self.model.groupdocs_guid = groupdocs_file.guid
13
+ if SUPPORTED_TYPES.include?(file.content_type)
14
+ groupdocs_file = GroupDocs::Storage::File.upload!(file.path, {name: file.filename}, client_id: self.groupdocs_client_id, private_key: self.groupdocs_private_key)
15
+ self.model.groupdocs_guid = groupdocs_file.guid
16
+ if self.model.respond_to?(:groupdocs_thumbnail=)
17
+ self.model.groupdocs_thumbnail = groupdocs_file.thumbnail
18
+ end
19
+ end
14
20
  end
15
21
  end
16
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-viewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000 Z
12
+ date: 2013-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: carrierwave