· 6 years ago · May 04, 2020, 04:04 AM
1
2# google-drive-uploader
3
4API interface to facilitate upload of files on Google Drive using Google drive API gateway.
5
6
7
8## Getting Started
9
10
11
12### Setup Ruby
13
14
15
16* Use `rbenv` or `rvm` for ruby setup. Installation steps are specified [here](https://github.com/rbenv/rbenv) and [here](https://rvm.io/).
17
18
19
20* Rails version- *6.0.2*
21
22
23
24* Ruby version - *2.7.0*.
25
26Install with the following commands (for `rvm`):
27
28
29```
30rvm install ruby-2.7.0
31
32rvm use 2.7.0
33```
34
35
36
37
38### Prerequisites
39
40
41
42
43
44Follow these [steps 1-8](https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md#command-line) to get the needed credentials.
45
46Add `client_id` and `client_secret` creds in google_drive.json file of project.
47The file should reside in `config` folder in `Rails.root`. Have added a `google_drive.json.sample` file for reference.
48
49
50
51
52
53### Local Setup
54
55Install the dependencies and start the server.
56
57
58
59
60```
61gem install bundler # if not already
62
63bundle install
64
65rails console
66
67# below in the rails console
68> drive_session = GoogleDrive::Session.from_config('config/google_drive.json')
69> # open the google link that comes up, grant the permissions, and paste the resultant code back in your terminal.
70> exit
71
72rails server
73```
74
75
76### Usage
77
78* Use an API client to call the REST API http://localhost:3000/upload (type POST), which requires one parameter to be passed as request body of form-data type.
79
80* In form-data, add one `key-value` pair: key `file` value will be the `file` to upload.
81
82* To add filter check append query param to the end of the url: key `enable_filter` value will be `true`
83
84### Output
85
86* Create a folder in google drive and upload files to it.