paperclip-google-drive 0.3.1 → 0.3.2

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: c7c2bb6eae67f447365e5f5e0a11a6a751582ba7
4
- data.tar.gz: 151052f23e6e53c2b785ec0aa65897ea90903bbe
3
+ metadata.gz: d485865dd71ce11f5d063479d008aa4d74139663
4
+ data.tar.gz: fd200560af8eced312efbbb333491014850fe923
5
5
  SHA512:
6
- metadata.gz: 02a3a5e97b90105dc8ac32789da4edb9e0074df2b863bcba7b6661e5bc469353f723c886a94bf18118bbffa0670e043e6b200492425eab44c9989b7d2e023b24
7
- data.tar.gz: 79ccd25892080cb5b41894086524ec6f43575d983b93b6bb9a3ab4586c4447ab522624d3243fa470e0f4b5787f24ea9bdefa85830a77f370ba1fc03dd700c6ba
6
+ metadata.gz: 2c3cd032542c05a0b14fd562a49ad06a019f0f4fdb6c792cdf417463ba646864216c3c58d558ac5ec351f5a581838e3e9855842c70360bec3697be24e1609662
7
+ data.tar.gz: ea829ce3a22b96546a2aafab8f33963e086e614a6a6766f0797602a3d4a50b32dbdf303d86040fe02ce8e3ca3924bd0ed92423a14776fae5a970f207894e350c
data/README.md CHANGED
@@ -79,6 +79,7 @@ This is a hash containing any of the following options:
79
79
  - `:application_name` - is the name that you set for the application credentials on Google console.
80
80
 
81
81
  The :path option should be a block that 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
  ```ruby
83
84
  class Product < ActiveRecord::Base
84
85
  has_attached_file :photo,
@@ -93,18 +94,24 @@ end
93
94
  ```
94
95
  For example, a new product is created with the ID of 14, and a some_photo.jpg as its photo. The following files would be saved to the Google Drive:
95
96
 
97
+ ```
96
98
  Public/14_some_photo.jpg
97
99
  Public/14_some_photo_medium.jpg
100
+ ```
98
101
 
99
102
  The another file is called some_photo_medium.jpg because style names (other than original) will always be appended to the filenames, for better management.
100
103
 
101
- Also, you can use the resize feature provided by GDrive API, you only have to pass as parameter in the url params the option `:custom` and `width`, as follows:
104
+ Also, you can use the resize feature provided by GDrive API, you only have to pass as parameter in the url params the option `:custom_thumb` and `:width`, as follows:
102
105
 
103
106
  ```ruby
104
- some_product.photo.url(:custom, width: 500)
107
+ some_product.photo.url(:custom_thumb, width: 500)
105
108
  ```
106
109
 
107
- ## Misc
110
+ ## Issues
111
+
112
+ ### No images Issues (PDF, CSV, etc)
113
+
114
+ I still working on retrieve the raw files, I would like to get the files as `thumbnail_link` file attribute does, but it is not that easy, because Google Drive API has some retrictions. Therefore, all non images files are shown in Google Drive viwer.
108
115
 
109
116
  ## Useful links
110
117
 
@@ -142,9 +142,12 @@ module Paperclip
142
142
  # @return [ String ] with url
143
143
  def public_url_for(title)
144
144
  metadata_or_default_img_from(title) do |metadata|
145
- # TODO: fix permission issues on the view with this command
146
145
  # effective_url_from(metadata.web_content_link)
147
- custom_thumbnail_image_for(metadata.thumbnail_link, 1000)
146
+ if content_type =~ /image/
147
+ custom_thumbnail_image_for(metadata.thumbnail_link, 1000)
148
+ else
149
+ metadata.web_view_link
150
+ end
148
151
  end
149
152
  end
150
153
 
@@ -169,6 +172,10 @@ module Paperclip
169
172
  "#{ file_url }=s#{ custom_width }"
170
173
  end
171
174
 
175
+ # TOO SLOW and PERMISSIONS ISSUES
176
+ # Seems that the retrieved file url is only visible for the
177
+ # user which is owner and is currently log in GDrive.
178
+ #
172
179
  # Gets the effective url from the web content link
173
180
  # These are a series of steps to hack the way that GDrive API
174
181
  # handle its urls. It consists in catch a Google::Apis::RedirectError error
@@ -223,6 +230,7 @@ module Paperclip
223
230
  raise 'the file name was not retrieved' if metadata.name.nil?
224
231
  raise 'the file thumbnail_link was not retrieved' if metadata.thumbnail_link.nil?
225
232
  raise 'the file web_content_link was not retrieved' if metadata.web_content_link.nil?
233
+ raise 'the file web_view_link was not retrieved' if metadata.web_view_link.nil?
226
234
  raise 'the file trashed was not retrieved' if metadata.trashed.nil?
227
235
  end
228
236
 
@@ -1,3 +1,3 @@
1
1
  module PaperclipGoogleDrive
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-google-drive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Gomez