paperclip-google-drive 0.2 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -13
- data/lib/paperclip/storage/google_drive.rb +2 -2
- data/lib/paperclip/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea643014b17dba645cc7be27b4e40344a477850d
|
4
|
+
data.tar.gz: b02d033f6903ca1c63b143549be498c902eef798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6502999e062f9a3bec85a781f6831bff4e1ad6d2b94c72234c4ea7c149f65097e81af5817b4575ea884ce1e7472248e17c7343dc048f870782752ab40107a47c
|
7
|
+
data.tar.gz: c24b8109949282ab6f5016cb92a1d309efc5c0d9f25a96290a1d575153ea2576c5ada1a7ae4268233e193adbd68a6bd071b59e52767713583ae0a783fd658488
|
data/README.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
#
|
2
|
-
[![
|
3
|
-
[![Code Climate](https://codeclimate.com/
|
1
|
+
# PaperclipGoogleDrive
|
2
|
+
[![GitHub version](https://badge.fury.io/gh/degzcs%2Fpaperclip-googledrive.svg)](https://badge.fury.io/gh/degzcs%2Fpaperclip-googledrive)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/degzcs/paperclip-googledrive/badges/gpa.svg)](https://codeclimate.com/github/degzcs/paperclip-googledrive)
|
4
4
|
|
5
|
-
PaperclipGoogledrive is a gem that extends paperclip storage for Google Drive (V3). Works with Rails 3.x. and later.
|
5
|
+
PaperclipGoogledrive is a gem that extends paperclip storage for Google Drive (V3). Works with Rails 3.x. and later.
|
6
|
+
IMPORTANT NOTE: This repo was forked and upgraded to use Google Drive V3.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
10
|
Add this line to your application's Gemfile:
|
10
11
|
|
11
|
-
gem 'paperclip-
|
12
|
+
gem 'paperclip-google-drive'
|
12
13
|
|
13
14
|
And then execute:
|
14
15
|
|
@@ -16,7 +17,7 @@ And then execute:
|
|
16
17
|
|
17
18
|
Or install it yourself as:
|
18
19
|
|
19
|
-
$ gem install paperclip-
|
20
|
+
$ gem install paperclip-google-drive
|
20
21
|
|
21
22
|
## Google Drive Setup
|
22
23
|
|
@@ -28,15 +29,15 @@ Google Drive is a free service for file storage files. In order to use this stor
|
|
28
29
|
|
29
30
|
3. Go to "API Manager > Credentials" and click on "OAuth Client ID" before to select "Other" type you must specify `http://localhost` for application home page.
|
30
31
|
|
31
|
-
4. Now you will have a Client ID, Client Secret, and Redirect URL. So, download the client_secret_XXXXX.json file and rename it to
|
32
|
+
4. Now you will have a Client ID, Client Secret, and Redirect URL. So, download the client_secret_XXXXX.json file and rename it to client_secret.json.
|
32
33
|
|
33
34
|
5. Run the authorization task:
|
34
35
|
```sh
|
35
|
-
$ rake google_drive:authorize"[path/to/client_secret.json application_name]"
|
36
|
+
$ rake google_drive:authorize"[path/to/client_secret.json, 'application_name']"
|
36
37
|
```
|
37
38
|
NOTE:
|
38
39
|
- the `path/to/client_secret.json` path is the file downloaded from Google console (it will be overrided with the fresh token).
|
39
|
-
- the application_name param is the name that you set for the application credentials on Google console.
|
40
|
+
- the `application_name` param is the name that you set for the application credentials on Google console.
|
40
41
|
|
41
42
|
6. The Rake task will give you an auth url. Simply go to that url (while signed in as the designated uploads owner), authorize the app, then enter code from url in the console. The rake task will override valid `client_secret.json` which you can use to connect with GoogleDrive from now on.
|
42
43
|
|
@@ -54,9 +55,9 @@ end
|
|
54
55
|
```
|
55
56
|
The `:google_drive_client_secret_path` option
|
56
57
|
|
57
|
-
|
58
|
+
This is the path of the file which was obtained from your Google Drive app settings and the authorization Rake task.
|
58
59
|
|
59
|
-
Example `path/to/client_secret.json
|
60
|
+
Example of the overridden `path/to/client_secret.json` file:
|
60
61
|
```json
|
61
62
|
{
|
62
63
|
"client_id": "4444-1111.apps.googleusercontent.com",
|
@@ -85,7 +86,8 @@ class Product < ActiveRecord::Base
|
|
85
86
|
:google_drive_client_secret_path => "#{Rails.root}/config/client_secret.json"
|
86
87
|
:styles => { :medium => "300x300" },
|
87
88
|
:google_drive_options => {
|
88
|
-
:path => proc { |style| "#{style}_#{id}_#{photo.original_filename}" }
|
89
|
+
:path => proc { |style| "#{style}_#{id}_#{photo.original_filename}" },
|
90
|
+
:public_folder_id => 'AAAARRRRGGGBBBFFFFadsasdX'
|
89
91
|
}
|
90
92
|
end
|
91
93
|
```
|
@@ -105,7 +107,7 @@ Useful links
|
|
105
107
|
|
106
108
|
[Enable the Drive API and SDK](https://developers.google.com/drive/enable-sdk)
|
107
109
|
|
108
|
-
[Quickstart](https://developers.google.com/drive/quickstart
|
110
|
+
[Quickstart](https://developers.google.com/drive/v3/web/quickstart/ruby)
|
109
111
|
|
110
112
|
## License
|
111
113
|
|
@@ -124,7 +124,7 @@ module Paperclip
|
|
124
124
|
default_image
|
125
125
|
else
|
126
126
|
metadata = metadata_by_id(searched_id)
|
127
|
-
metadata.web_content_link #or metadata.web_view_link?
|
127
|
+
metadata.thumbnail_link #web_content_link #or metadata.web_view_link?
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -180,7 +180,7 @@ module Paperclip
|
|
180
180
|
title = @google_drive_options[:default_url]
|
181
181
|
searched_id = search_for_title(title) # id
|
182
182
|
metadata = metadata_by_id(searched_id) unless searched_id.nil?
|
183
|
-
metadata.web_content_link
|
183
|
+
metadata.thumbnail_link#web_view_link #web_content_link
|
184
184
|
else
|
185
185
|
'No picture' # ---- ?
|
186
186
|
end
|
data/lib/paperclip/version.rb
CHANGED