shrine-google_drive_storage 0.3.6 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/shrine/storage/google_drive_storage.rb +4 -3
- 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: cf11ee5e155a79f5f4b4df8f676c7a2358a98fde
|
4
|
+
data.tar.gz: ced7a62f10dc54614dd2ea09fa224de6097cdfcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0c3260b294e3b7fd74af5dd43759be12e766471cbac849c95a06bb8b0026d63263c181f9cb32deeae0267bf6ea99d0f87b9b82c008498407d8668f05c753217
|
7
|
+
data.tar.gz: 38edc79087c650872fcc652cd01cb27856420b847d7ea71c6e5335afa3d05689773ac99dd28931cfc8398f3e935b427d4229d279d3cf63a48ceea323f92f8fe7
|
data/README.md
CHANGED
@@ -49,9 +49,9 @@ Shrine.storages = {
|
|
49
49
|
Shrine::Storage::GoogleDriveStorage.new(
|
50
50
|
prefix: "store",
|
51
51
|
google_drive_client_secret_path: "#{Rails.root}/config/client_secret.json",
|
52
|
+
drive_public_folder_id: 'AAAARRRRGGGBBBFFFFadsasdX',
|
52
53
|
google_drive_options: {
|
53
54
|
path: proc { |style| "#{id}_#{photo.original_filename}_#{style}" },
|
54
|
-
public_folder_id: 'AAAARRRRGGGBBBFFFFadsasdX'
|
55
55
|
},
|
56
56
|
)
|
57
57
|
```
|
@@ -60,6 +60,10 @@ The `:google_drive_client_secret_path` option
|
|
60
60
|
|
61
61
|
This is the path of the file downloaded from your Google Drive app settings by the authorization Rake task.
|
62
62
|
|
63
|
+
The `:drive_public_folder_id` option
|
64
|
+
|
65
|
+
This is the id of Google Drive folder that must be created in google drive and set public permissions on it
|
66
|
+
|
63
67
|
Example of the overridden `path/to/client_secret.json` file:
|
64
68
|
```json
|
65
69
|
{
|
@@ -77,9 +81,7 @@ The `:google_drive_options` option
|
|
77
81
|
|
78
82
|
This is a hash containing any of the following options:
|
79
83
|
- `:path` – block
|
80
|
-
- `:public_folder_id`- id of folder that must be created in google drive and set public permissions on it
|
81
84
|
- `:default_image` - an image in Public folder that used for attachments if attachment is not present
|
82
|
-
- `:application_name` - is the name that you set for the application credentials on Google console.
|
83
85
|
|
84
86
|
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.
|
85
87
|
|
@@ -12,8 +12,9 @@ class Shrine
|
|
12
12
|
|
13
13
|
def initialize(prefix: nil, google_drive_options: {})
|
14
14
|
@prefix = prefix
|
15
|
-
@google_drive_client_secret_path =
|
16
|
-
@
|
15
|
+
@google_drive_client_secret_path = google_drive_client_secret_path
|
16
|
+
@drive_public_folder_id = drive_public_folder_id
|
17
|
+
@google_drive_options = google_drive_options
|
17
18
|
end
|
18
19
|
|
19
20
|
def upload(io, id, shrine_metadata: {}, **_options)
|
@@ -22,7 +23,7 @@ class Shrine
|
|
22
23
|
name: id,
|
23
24
|
description: 'shrine file on google drive',
|
24
25
|
mimeType: mime_type,
|
25
|
-
parents:
|
26
|
+
parents: @drive_public_folder_id
|
26
27
|
}
|
27
28
|
|
28
29
|
google_api_client.create_file(
|