activestorage-dropbox 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +175 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +6 -0
- data/activestorage-dropbox.gemspec +32 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/.DS_Store +0 -0
- data/lib/active_storage/.DS_Store +0 -0
- data/lib/active_storage/service/.DS_Store +0 -0
- data/lib/active_storage/service/dropbox_service.rb +100 -0
- data/lib/active_storage/service/version.rb +5 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0eb58181da24e468339147694bb72d06f1f94fd3b077ceaf88f8dd3625ce9451
|
4
|
+
data.tar.gz: 63bf2273e600147b11db0ad55fd912a7f358bc8da0fd8fc2bff6a3886fe76ea8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3f33ac20a48371732afeb0965c81924204c830c8de007506d9d3a90bddca589593af6b577e055bf97f08bfdfd03aa610e7134b6244e43a52db73e97fe982877
|
7
|
+
data.tar.gz: 00ecbde3e0087d4608a5d6ca0604924f7ea981feb589d41745ce44da5a7b9536b7791629622f2903b03944245a72985e3edfb5f19fc161454cd77e1113d6ab26
|
data/.DS_Store
ADDED
Binary file
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at mail@ashishprajapati.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
activestorage-dropbox (0.1.1)
|
5
|
+
dropbox_api (~> 0.1.16)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (5.2.2.1)
|
11
|
+
actionpack (= 5.2.2.1)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailer (5.2.2.1)
|
15
|
+
actionpack (= 5.2.2.1)
|
16
|
+
actionview (= 5.2.2.1)
|
17
|
+
activejob (= 5.2.2.1)
|
18
|
+
mail (~> 2.5, >= 2.5.4)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
actionpack (5.2.2.1)
|
21
|
+
actionview (= 5.2.2.1)
|
22
|
+
activesupport (= 5.2.2.1)
|
23
|
+
rack (~> 2.0)
|
24
|
+
rack-test (>= 0.6.3)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
+
actionview (5.2.2.1)
|
28
|
+
activesupport (= 5.2.2.1)
|
29
|
+
builder (~> 3.1)
|
30
|
+
erubi (~> 1.4)
|
31
|
+
rails-dom-testing (~> 2.0)
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
+
activejob (5.2.2.1)
|
34
|
+
activesupport (= 5.2.2.1)
|
35
|
+
globalid (>= 0.3.6)
|
36
|
+
activemodel (5.2.2.1)
|
37
|
+
activesupport (= 5.2.2.1)
|
38
|
+
activerecord (5.2.2.1)
|
39
|
+
activemodel (= 5.2.2.1)
|
40
|
+
activesupport (= 5.2.2.1)
|
41
|
+
arel (>= 9.0)
|
42
|
+
activestorage (5.2.2.1)
|
43
|
+
actionpack (= 5.2.2.1)
|
44
|
+
activerecord (= 5.2.2.1)
|
45
|
+
marcel (~> 0.3.1)
|
46
|
+
activesupport (5.2.2.1)
|
47
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
+
i18n (>= 0.7, < 2)
|
49
|
+
minitest (~> 5.1)
|
50
|
+
tzinfo (~> 1.1)
|
51
|
+
arel (9.0.0)
|
52
|
+
builder (3.2.3)
|
53
|
+
concurrent-ruby (1.1.5)
|
54
|
+
coveralls (0.8.22)
|
55
|
+
json (>= 1.8, < 3)
|
56
|
+
simplecov (~> 0.16.1)
|
57
|
+
term-ansicolor (~> 1.3)
|
58
|
+
thor (~> 0.19.4)
|
59
|
+
tins (~> 1.6)
|
60
|
+
crass (1.0.4)
|
61
|
+
diff-lcs (1.3)
|
62
|
+
docile (1.3.1)
|
63
|
+
dropbox_api (0.1.16)
|
64
|
+
faraday (>= 0.8, <= 0.15.4)
|
65
|
+
oauth2 (~> 1.1)
|
66
|
+
erubi (1.8.0)
|
67
|
+
faraday (0.15.4)
|
68
|
+
multipart-post (>= 1.2, < 3)
|
69
|
+
globalid (0.4.2)
|
70
|
+
activesupport (>= 4.2.0)
|
71
|
+
i18n (1.6.0)
|
72
|
+
concurrent-ruby (~> 1.0)
|
73
|
+
json (2.2.0)
|
74
|
+
jwt (2.1.0)
|
75
|
+
loofah (2.2.3)
|
76
|
+
crass (~> 1.0.2)
|
77
|
+
nokogiri (>= 1.5.9)
|
78
|
+
mail (2.7.1)
|
79
|
+
mini_mime (>= 0.1.1)
|
80
|
+
marcel (0.3.3)
|
81
|
+
mimemagic (~> 0.3.2)
|
82
|
+
method_source (0.9.2)
|
83
|
+
mimemagic (0.3.3)
|
84
|
+
mini_mime (1.0.1)
|
85
|
+
mini_portile2 (2.4.0)
|
86
|
+
minitest (5.11.3)
|
87
|
+
multi_json (1.13.1)
|
88
|
+
multi_xml (0.6.0)
|
89
|
+
multipart-post (2.0.0)
|
90
|
+
nio4r (2.3.1)
|
91
|
+
nokogiri (1.10.1)
|
92
|
+
mini_portile2 (~> 2.4.0)
|
93
|
+
oauth2 (1.4.1)
|
94
|
+
faraday (>= 0.8, < 0.16.0)
|
95
|
+
jwt (>= 1.0, < 3.0)
|
96
|
+
multi_json (~> 1.3)
|
97
|
+
multi_xml (~> 0.5)
|
98
|
+
rack (>= 1.2, < 3)
|
99
|
+
rack (2.0.6)
|
100
|
+
rack-test (1.1.0)
|
101
|
+
rack (>= 1.0, < 3)
|
102
|
+
rails (5.2.2.1)
|
103
|
+
actioncable (= 5.2.2.1)
|
104
|
+
actionmailer (= 5.2.2.1)
|
105
|
+
actionpack (= 5.2.2.1)
|
106
|
+
actionview (= 5.2.2.1)
|
107
|
+
activejob (= 5.2.2.1)
|
108
|
+
activemodel (= 5.2.2.1)
|
109
|
+
activerecord (= 5.2.2.1)
|
110
|
+
activestorage (= 5.2.2.1)
|
111
|
+
activesupport (= 5.2.2.1)
|
112
|
+
bundler (>= 1.3.0)
|
113
|
+
railties (= 5.2.2.1)
|
114
|
+
sprockets-rails (>= 2.0.0)
|
115
|
+
rails-dom-testing (2.0.3)
|
116
|
+
activesupport (>= 4.2.0)
|
117
|
+
nokogiri (>= 1.6)
|
118
|
+
rails-html-sanitizer (1.0.4)
|
119
|
+
loofah (~> 2.2, >= 2.2.2)
|
120
|
+
railties (5.2.2.1)
|
121
|
+
actionpack (= 5.2.2.1)
|
122
|
+
activesupport (= 5.2.2.1)
|
123
|
+
method_source
|
124
|
+
rake (>= 0.8.7)
|
125
|
+
thor (>= 0.19.0, < 2.0)
|
126
|
+
rake (10.5.0)
|
127
|
+
rspec (3.8.0)
|
128
|
+
rspec-core (~> 3.8.0)
|
129
|
+
rspec-expectations (~> 3.8.0)
|
130
|
+
rspec-mocks (~> 3.8.0)
|
131
|
+
rspec-core (3.8.0)
|
132
|
+
rspec-support (~> 3.8.0)
|
133
|
+
rspec-expectations (3.8.2)
|
134
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
135
|
+
rspec-support (~> 3.8.0)
|
136
|
+
rspec-mocks (3.8.0)
|
137
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
138
|
+
rspec-support (~> 3.8.0)
|
139
|
+
rspec-support (3.8.0)
|
140
|
+
simplecov (0.16.1)
|
141
|
+
docile (~> 1.1)
|
142
|
+
json (>= 1.8, < 3)
|
143
|
+
simplecov-html (~> 0.10.0)
|
144
|
+
simplecov-html (0.10.2)
|
145
|
+
sprockets (3.7.2)
|
146
|
+
concurrent-ruby (~> 1.0)
|
147
|
+
rack (> 1, < 3)
|
148
|
+
sprockets-rails (3.2.1)
|
149
|
+
actionpack (>= 4.0)
|
150
|
+
activesupport (>= 4.0)
|
151
|
+
sprockets (>= 3.0.0)
|
152
|
+
term-ansicolor (1.7.1)
|
153
|
+
tins (~> 1.0)
|
154
|
+
thor (0.19.4)
|
155
|
+
thread_safe (0.3.6)
|
156
|
+
tins (1.20.2)
|
157
|
+
tzinfo (1.2.5)
|
158
|
+
thread_safe (~> 0.1)
|
159
|
+
websocket-driver (0.7.0)
|
160
|
+
websocket-extensions (>= 0.1.0)
|
161
|
+
websocket-extensions (0.1.3)
|
162
|
+
|
163
|
+
PLATFORMS
|
164
|
+
ruby
|
165
|
+
|
166
|
+
DEPENDENCIES
|
167
|
+
activestorage-dropbox!
|
168
|
+
bundler (~> 2.0)
|
169
|
+
coveralls (~> 0.8.22)
|
170
|
+
rails (>= 5.2)
|
171
|
+
rake (~> 10.0)
|
172
|
+
rspec (~> 3.0)
|
173
|
+
|
174
|
+
BUNDLED WITH
|
175
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Ashish Prajapati
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Dropbox Support for Active Storage - Official Gem
|
2
|
+
### Activestorage::Service::DropboxService
|
3
|
+
|
4
|
+
Rails ActiveStorage adapter for Dropbox. Wraps the [Dropbox](https://www.dropbox.com/) Storage Service as an Active Storage service.
|
5
|
+
|
6
|
+
[![Version](https://img.shields.io/gem/v/activestorage-dropbox.svg?style=flat-square)](https://rubygems.org/gems/activestorage-dropbox)
|
7
|
+
[![Build Status](https://travis-ci.org/ashishprajapati/activestorage-dropbox.svg?branch=master)](https://travis-ci.org/ashishprajapati/activestorage-dropbox)
|
8
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/629942b6297330c3f52f/maintainability)](https://codeclimate.com/github/ashishprajapati/activestorage-dropbox/maintainability)
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/activestorage-dropbox.svg)](https://badge.fury.io/rb/activestorage-dropbox)
|
10
|
+
|
11
|
+
Reference: https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/rOj4y3hx0Gc
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'activestorage-dropbox'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install activestorage-dropbox
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
Declare an Dropbox service in config/storage.yml
|
31
|
+
|
32
|
+
```
|
33
|
+
dropbox:
|
34
|
+
service: Dropbox
|
35
|
+
access_token: ""
|
36
|
+
```
|
37
|
+
|
38
|
+
To use the Dropbox service in development, you add the following to config/environments/development.rb:
|
39
|
+
|
40
|
+
```
|
41
|
+
config.active_storage.service = :dropbox
|
42
|
+
```
|
43
|
+
|
44
|
+
To use the Dropbox service in production, you add the following to config/environments/production.rb:
|
45
|
+
|
46
|
+
```
|
47
|
+
config.active_storage.service = :dropbox
|
48
|
+
```
|
49
|
+
|
50
|
+
You can read more about Active Storage in the [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html) guide.
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activestorage-dropbox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
65
|
+
|
66
|
+
## Code of Conduct
|
67
|
+
|
68
|
+
Everyone interacting in the ActivestorageDropbox project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/activestorage-dropbox/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'active_storage/service/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "activestorage-dropbox"
|
7
|
+
spec.version = ActiveStorage::DropboxService::VERSION
|
8
|
+
spec.authors = ["Ashish Prajapati"]
|
9
|
+
spec.email = ["mail@ashishprajapati.com"]
|
10
|
+
|
11
|
+
spec.summary = '[Official] Rails ActiveStorage adapter for Dropbox. Wraps the Dropbox Storage as an Active Storage service. Active Storage Dropbox Official Gem (activestorage dropbox support) - https://www.dropbox.com'
|
12
|
+
spec.description = '[Official] Rails ActiveStorage adapter for Dropbox. Wraps the Dropbox Storage as an Active Storage service. Active Storage Dropbox Official Gem (activestorage dropbox support) - https://www.dropbox.com'
|
13
|
+
spec.homepage = "https://github.com/ashishprajapati/activestorage-dropbox"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "coveralls", "~> 0.8.22"
|
29
|
+
spec.add_development_dependency "rails", ">= 5.2"
|
30
|
+
|
31
|
+
spec.add_dependency "dropbox_api", "~> 0.1.16"
|
32
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "active_storage/service/dropbox_service"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dropbox_api"
|
4
|
+
|
5
|
+
module ActiveStorage
|
6
|
+
# Wraps the Dropbox Storage as an Active Storage service. See ActiveStorage::Service for the generic API
|
7
|
+
# documentation that applies to all services.
|
8
|
+
class Service::DropboxService < Service
|
9
|
+
def initialize(**config)
|
10
|
+
@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
def upload(key, io, checksum: nil, content_type: nil, disposition: nil, filename: nil)
|
14
|
+
instrument :upload, key: key, checksum: checksum do
|
15
|
+
client.upload_by_chunks "/"+key, io
|
16
|
+
rescue DropboxApi::Errors::UploadError
|
17
|
+
raise ActiveStorage::IntegrityError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def download(key, &block)
|
22
|
+
if block_given?
|
23
|
+
instrument :streaming_download, key: key do
|
24
|
+
stream(key, &block)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
instrument :download, key: key do
|
28
|
+
download_for(key)
|
29
|
+
rescue DropboxApi::Errors::NotFoundError
|
30
|
+
raise ActiveStorage::FileNotFoundError
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete(key)
|
36
|
+
instrument :delete, key: key do
|
37
|
+
client.delete("/"+key)
|
38
|
+
rescue DropboxApi::Errors::NotFoundError
|
39
|
+
# Ignore files already deleted
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete_prefixed(prefix)
|
44
|
+
instrument :delete_prefixed, prefix: prefix do
|
45
|
+
client.delete("/"+prefix[0..-2])
|
46
|
+
rescue DropboxApi::Errors::NotFoundError
|
47
|
+
# Ignore files already deleted
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def exist?(key)
|
52
|
+
instrument :exist, key: key do |payload|
|
53
|
+
begin
|
54
|
+
answer = client.get_metadata("/"+key).present?
|
55
|
+
rescue DropboxApi::Errors::NotFoundError
|
56
|
+
answer = false
|
57
|
+
end
|
58
|
+
payload[:exist] = answer
|
59
|
+
answer
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def url(key, expires_in:, filename:, disposition:, content_type:)
|
64
|
+
instrument :url, key: key do |payload|
|
65
|
+
generated_url = file_for(key).link
|
66
|
+
payload[:url] = generated_url
|
67
|
+
generated_url
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
attr_reader :config
|
74
|
+
|
75
|
+
def file_for(key)
|
76
|
+
client.get_temporary_link("/"+key)
|
77
|
+
end
|
78
|
+
|
79
|
+
def download_for(key)
|
80
|
+
client.download("/"+key) do |chunk|
|
81
|
+
return chunk.force_encoding(Encoding::BINARY)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Reads the file for the given key in chunks, yielding each to the block.
|
86
|
+
def stream(key)
|
87
|
+
begin
|
88
|
+
file = client.download("/"+key) do |chunk|
|
89
|
+
yield chunk
|
90
|
+
end
|
91
|
+
rescue DropboxApi::Errors::NotFoundError
|
92
|
+
raise ActiveStorage::FileNotFoundError
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def client
|
97
|
+
@client ||= DropboxApi::Client.new(config.fetch(:access_token))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activestorage-dropbox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ashish Prajapati
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.22
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.22
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dropbox_api
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.16
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.16
|
97
|
+
description: "[Official] Rails ActiveStorage adapter for Dropbox. Wraps the Dropbox
|
98
|
+
Storage as an Active Storage service. Active Storage Dropbox Official Gem (activestorage
|
99
|
+
dropbox support) - https://www.dropbox.com"
|
100
|
+
email:
|
101
|
+
- mail@ashishprajapati.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".DS_Store"
|
107
|
+
- ".coveralls.yml"
|
108
|
+
- ".gitignore"
|
109
|
+
- ".rspec"
|
110
|
+
- ".travis.yml"
|
111
|
+
- CODE_OF_CONDUCT.md
|
112
|
+
- Gemfile
|
113
|
+
- Gemfile.lock
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- activestorage-dropbox.gemspec
|
118
|
+
- bin/console
|
119
|
+
- bin/setup
|
120
|
+
- lib/.DS_Store
|
121
|
+
- lib/active_storage/.DS_Store
|
122
|
+
- lib/active_storage/service/.DS_Store
|
123
|
+
- lib/active_storage/service/dropbox_service.rb
|
124
|
+
- lib/active_storage/service/version.rb
|
125
|
+
homepage: https://github.com/ashishprajapati/activestorage-dropbox
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubygems_version: 3.0.3
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: "[Official] Rails ActiveStorage adapter for Dropbox. Wraps the Dropbox Storage
|
148
|
+
as an Active Storage service. Active Storage Dropbox Official Gem (activestorage
|
149
|
+
dropbox support) - https://www.dropbox.com"
|
150
|
+
test_files: []
|