paperclip-google-drive 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/paperclip/storage/google_drive.rb +5 -2
- data/lib/paperclip/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: 1b74ffa08b048d2007804f535d7140e8dad3cf2b
|
4
|
+
data.tar.gz: f3d3f431d990e0a52fa812d1f6acc400695b7192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7af735b0d18245973e71350aec1cbeb67324e29086487eeafada81f692706ba34956a80a79f5781748739c9468e42d0c70cb386d52eff8427c8ec000a8dfa613
|
7
|
+
data.tar.gz: c1daa97b8e09031b706322f010147038c883152a895d5c11fcb493936e4e314e76e3fb82df6a16a1107341d9ad48e57b601fecccbcfbddbeeed80f3b0d1e512d
|
data/README.md
CHANGED
@@ -55,7 +55,7 @@ end
|
|
55
55
|
```
|
56
56
|
The `:google_drive_client_secret_path` option
|
57
57
|
|
58
|
-
This is the path of the file
|
58
|
+
This is the path of the file downloaded from your Google Drive app settings by the authorization Rake task.
|
59
59
|
|
60
60
|
Example of the overridden `path/to/client_secret.json` file:
|
61
61
|
```json
|
@@ -78,7 +78,7 @@ This is a hash containing any of the following options:
|
|
78
78
|
- `:default_image` - an image in Public folder that used for attachments if attachment is not present
|
79
79
|
- `:application_name` - is the name that you set for the application credentials on Google console.
|
80
80
|
|
81
|
-
The :path option should be a block
|
81
|
+
The :path option should be a block which returns a path that the uploaded file should be saved to. The block yields the attachment style and is executed in the scope of the model instance. For example:
|
82
82
|
|
83
83
|
```ruby
|
84
84
|
class Product < ActiveRecord::Base
|
@@ -107,11 +107,15 @@ Also, you can use the resize feature provided by GDrive API, you only have to pa
|
|
107
107
|
some_product.photo.url(:custom_thumb, width: 500)
|
108
108
|
```
|
109
109
|
|
110
|
+
## Example App
|
111
|
+
|
112
|
+
You can find an example of how to config a Rails project [here](https://github.com/degzcs/rails-paperclip-gdrive-example)
|
113
|
+
|
110
114
|
## Issues
|
111
115
|
|
112
|
-
###
|
116
|
+
### Non image files Issues (PDF, CSV, etc)
|
113
117
|
|
114
|
-
I still working on retrieve the raw files, I would like to get the
|
118
|
+
I still working on retrieve the raw files, I would like to get the file urls as `thumbnail_link` attribute does, but it is not that easy, because Google Drive API has some retrictions. So, all non image files are shown in Google Drive viewer.
|
115
119
|
|
116
120
|
## Useful links
|
117
121
|
|
@@ -109,7 +109,7 @@ module Paperclip
|
|
109
109
|
if present?
|
110
110
|
style = args.first.is_a?(Symbol) ? args.first : default_style
|
111
111
|
options = args.last.is_a?(Hash) ? args.last : {}
|
112
|
-
if style == :custom_thumb
|
112
|
+
if style == :custom_thumb && is_valid_for_custom_thumb?
|
113
113
|
custom_width = options[:width] || 220
|
114
114
|
file_name = filename_from(default_style)
|
115
115
|
public_url_custom_thumbnail_from(file_name, custom_width)
|
@@ -122,6 +122,10 @@ module Paperclip
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
def is_valid_for_custom_thumb?
|
126
|
+
content_type =~ /image/ || content_type =~ /pdf/
|
127
|
+
end
|
128
|
+
|
125
129
|
# Gets full title/name
|
126
130
|
# @param style [ String ]
|
127
131
|
# @return [ String ]
|
@@ -228,7 +232,6 @@ module Paperclip
|
|
228
232
|
def validate_metadata(metadata)
|
229
233
|
raise 'the file id was not retrieved' if metadata.id.nil?
|
230
234
|
raise 'the file name was not retrieved' if metadata.name.nil?
|
231
|
-
raise 'the file thumbnail_link was not retrieved' if metadata.thumbnail_link.nil?
|
232
235
|
raise 'the file web_content_link was not retrieved' if metadata.web_content_link.nil?
|
233
236
|
raise 'the file web_view_link was not retrieved' if metadata.web_view_link.nil?
|
234
237
|
raise 'the file trashed was not retrieved' if metadata.trashed.nil?
|
data/lib/paperclip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-google-drive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paperclip
|