fog-dropbox 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rubocop.yml +20 -0
- data/.ruby-env.example +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +47 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +73 -0
- data/Rakefile +12 -0
- data/fog-dropbox.gemspec +33 -0
- data/lib/fog/bin/dropbox.rb +70 -0
- data/lib/fog/dropbox.rb +17 -0
- data/lib/fog/dropbox/models/storage/directories.rb +26 -0
- data/lib/fog/dropbox/models/storage/directory.rb +40 -0
- data/lib/fog/dropbox/models/storage/file.rb +78 -0
- data/lib/fog/dropbox/models/storage/files.rb +41 -0
- data/lib/fog/dropbox/storage.rb +44 -0
- data/lib/fog/dropbox/version.rb +5 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/directories/all.yml +170 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/directories/get.yml +207 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/directory/destroy.yml +171 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/directory/files.yml +262 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/directory/save.yml +208 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/file/destroy.yml +287 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/file/large_file.yml +278 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/file/small_file.yml +239 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/file/string.yml +519 -0
- data/spec/fixtures/vcr_cassettes/fog/storage/dropbox/files.yml +554 -0
- data/spec/fog/dropbox/models/storage/directories_spec.rb +49 -0
- data/spec/fog/dropbox/models/storage/directory_spec.rb +65 -0
- data/spec/fog/dropbox/models/storage/file_spec.rb +106 -0
- data/spec/fog/dropbox/models/storage/files_spec.rb +90 -0
- data/spec/fog/dropbox/storage_spec.rb +15 -0
- data/spec/spec_helper.rb +8 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5d8f7aedc723f59ed75ad25a600f97b6bb8728db
|
4
|
+
data.tar.gz: e08b2ebda7e9a464583d30475f7ee4ccb1ce580e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bae135f1e8ff2d15b89bf4df787ffebe047503ed9c05ab2d45f2ae6ecbb65b9c62b77192f6dede3eb9966bfb3179685be7af7b59e5124c69b44448037743e7b
|
7
|
+
data.tar.gz: 3369dca711ec356814c05a40b8021bd012f188e0b95abba7540c18f4244f6e252e49ba46e2ff17b47451d9f3afe1a7660ac26b11313a519ec6dca969410081b5
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Metrics/LineLength:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/EachWithObject:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Style/Encoding:
|
8
|
+
EnforcedStyle: when_needed
|
9
|
+
|
10
|
+
Style/FormatString:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/HashSyntax:
|
14
|
+
EnforcedStyle: hash_rockets
|
15
|
+
|
16
|
+
Style/SignalException:
|
17
|
+
EnforcedStyle: only_raise
|
18
|
+
|
19
|
+
Style/StringLiterals:
|
20
|
+
EnforcedStyle: double_quotes
|
data/.ruby-env.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
DROPBOX_OAUTH2_ACCESS_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXX
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
fog-dropbox
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Getting Involved
|
2
|
+
|
3
|
+
New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
|
4
|
+
|
5
|
+
### Coding
|
6
|
+
|
7
|
+
* Pick a task:
|
8
|
+
* Offer feedback on open [pull requests](https://github.com/zshannon/fog-dropbox/pulls).
|
9
|
+
* Review open [issues](https://github.com/zshannon/fog-dropbox/issues) for things to help on.
|
10
|
+
* [Create an issue](https://github.com/zshannon/fog-dropbox/issues/new) to start a discussion on additions or features.
|
11
|
+
* Fork the project, add your changes and tests to cover them in a topic branch.
|
12
|
+
* Commit your changes and rebase against `zshannon/fog-dropbox` to ensure everything is up to date.
|
13
|
+
* [Submit a pull request](https://github.com/zshannon/fog-dropbox/compare/)
|
14
|
+
|
15
|
+
### Non-Coding
|
16
|
+
|
17
|
+
* Offer feedback on open [issues](https://github.com/zshannon/fog-dropbox/issues).
|
18
|
+
* Organize or volunteer at events.
|
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
This repo was forked from fog/fog-google.
|
2
|
+
|
3
|
+
zshannon/fog-dropbox Contributors
|
4
|
+
* Zane Shannon <zane@zaneshannon.com>
|
5
|
+
|
6
|
+
Original fog/fog-google Contributors:
|
7
|
+
* Alexander Lomov <lomov.as@gmail.com>
|
8
|
+
* Alexander Kolesen <akolesen@iron.io>
|
9
|
+
* althras <althras@gmail.com>
|
10
|
+
* Andrew Leonard <andy@hurricane-ridge.com>
|
11
|
+
* Antonio <0x414f@gmail.com>
|
12
|
+
* Ariel Zavala <arielo.zavala@gmail.com>
|
13
|
+
* ashmrtnz <ashmrtnz@google.com>
|
14
|
+
* Akshay Moghe <amoghe@maginatics.com>
|
15
|
+
* Benson Kalahar <bensonk42@gmail.com>
|
16
|
+
* Bob Lail and Luke Booth <pair=bob.lail+luke.booth@cphepdev.com>
|
17
|
+
* Brett Porter <brett@apache.org>
|
18
|
+
* Brian D. Burns <iosctr@gmail.com>
|
19
|
+
* Carlos Sanchez <csanchez@maestrodev.com>
|
20
|
+
* Chris Gianelloni <wolf31o2@gmail.com>
|
21
|
+
* Dan Prince <dprince@redhat.com>
|
22
|
+
* Daniel Broudy <broudy@google.com>
|
23
|
+
* Doug Henderson <dhenderson@maestrodev.com>
|
24
|
+
* Eric Johnson <erjohnso@google.com>
|
25
|
+
* Ferran Rodenas <frodenas@gmail.com>
|
26
|
+
* Frederick Cheung <frederick.cheung@gmail.com>
|
27
|
+
* Jacob Mattingley <jem@ubalo.com>
|
28
|
+
* James Herdman <james.herdman@me.com>
|
29
|
+
* jordangbull <jordangbull@gmail.com>
|
30
|
+
* Juris Galang <jurisgalang@gmail.com>
|
31
|
+
* kbockmanrs <kevin@rightscale.com>
|
32
|
+
* Lance Ivy <lance@cainlevy.net>
|
33
|
+
* leonidlm <leonidlm@gmail.com>
|
34
|
+
* Marcin Owsiany <porridge@google.com>
|
35
|
+
* Matt Darby <matt.darby@rackspace.com>
|
36
|
+
* Michael Elfassy <michaelelfassy@napps.ca>
|
37
|
+
* Nat Welch <nat@natwelch.com>
|
38
|
+
* neillturner <neillwturner@gmail.com>
|
39
|
+
* Paul Thornthwaite <tokengeek@gmail.com>
|
40
|
+
* Paulo Henrique Lopes Ribeiro <plribeiro@zertico.com>
|
41
|
+
* Romain Haenni <admin@zlabs.ch>
|
42
|
+
* Romain Vrignaud <rvrignaud@gmail.com>
|
43
|
+
* snyquist2 <snyquist@google.com>
|
44
|
+
* Stephen von Takach <steve@advancedcontrol.com.au>
|
45
|
+
* Timur Alperovich <timur.alperovich@gmail.com>
|
46
|
+
* unknown <bturner_2@pibuk-lp71.pibenchmark.com>
|
47
|
+
* Wesley Beary <geemus@gmail.com>
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 [CONTRIBUTORS.md](https://github.com/zshannon/fog-dropbox/blob/master/CONTRIBUTORS.md)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Fog::Dropbox
|
2
|
+
|
3
|
+
Fog's great! Let's support Dropbox.
|
4
|
+
|
5
|
+
## Storage
|
6
|
+
|
7
|
+
### Application Setup
|
8
|
+
|
9
|
+
You're going to need to setup a [Dropbox Application](https://www.dropbox.com/developers/apps).
|
10
|
+
- Select `Dropbox API App` (not Drop-ins App).
|
11
|
+
- Select `Files and datastores`
|
12
|
+
- Select can be limited to its own folder (unless yours can't, but it probably can).
|
13
|
+
|
14
|
+
Click `Generate Access Token` to create an OAuth2 access token for your account. Grab this.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'fog-dropbox'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install fog-dropbox
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
fog_client = Fog::Storage::Dropbox.new(:dropbox_oauth2_access_token => ENV['DROPBOX_OAUTH2_ACCESS_TOKEN'])
|
36
|
+
|
37
|
+
# Read directory
|
38
|
+
folder = "/folder"
|
39
|
+
filename = "file"
|
40
|
+
key = [folder, filename].join('/')
|
41
|
+
directory = fog_client.directories.get(folder)
|
42
|
+
puts directory.inspect
|
43
|
+
|
44
|
+
# Read file
|
45
|
+
file = directory.files.get(key)
|
46
|
+
puts file.inspect
|
47
|
+
puts file.body
|
48
|
+
|
49
|
+
# Get file share link
|
50
|
+
puts file.url()
|
51
|
+
|
52
|
+
# Write string
|
53
|
+
file.body = "New Content"
|
54
|
+
file.save()
|
55
|
+
|
56
|
+
# Write large file
|
57
|
+
large_file = Tempfile.new("fog-dropbox-multipart")
|
58
|
+
6.times { large_file.write("x" * (1024**2)) } # 6 MB file
|
59
|
+
large_file.rewind
|
60
|
+
file.body = large_file
|
61
|
+
file.save()
|
62
|
+
|
63
|
+
# Delete
|
64
|
+
file.destroy()
|
65
|
+
```
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
1. Fork it ( https://github.com/zshannon/fog-dropbox/fork )
|
70
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
71
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
72
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
73
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
Dir["tasks/**/*.rake"].each do |file|
|
5
|
+
load(file)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Setup new RSpec for rake task
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
|
+
|
11
|
+
# make default task to run specs
|
12
|
+
task :default => :spec
|
data/fog-dropbox.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fog/dropbox/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fog-dropbox"
|
8
|
+
spec.version = Fog::Dropbox::VERSION
|
9
|
+
spec.authors = ["Zane Shannon"]
|
10
|
+
spec.email = ["zane@zaneshannon.com"]
|
11
|
+
spec.summary = %q{Module for the 'fog' gem to support Dropbox.}
|
12
|
+
spec.description = %q{This library can be used as a module for `fog` or as standalone provider
|
13
|
+
to use Dropbox in applications.}
|
14
|
+
spec.homepage = "https://github.com/zshannon/fog-dropbox"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'fog-core'
|
23
|
+
spec.add_dependency 'dropbox-sdk'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'vcr'
|
27
|
+
spec.add_development_dependency 'webmock'
|
28
|
+
|
29
|
+
if RUBY_VERSION.to_f > 1.9
|
30
|
+
spec.add_development_dependency 'coveralls'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Dropbox # deviates from other bin stuff to accomodate gem
|
2
|
+
class << self
|
3
|
+
def class_for(key)
|
4
|
+
case key
|
5
|
+
when :storage
|
6
|
+
Fog::Storage::Dropbox
|
7
|
+
else
|
8
|
+
raise ArgumentError, "Unsupported #{self} service: #{key}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](service)
|
13
|
+
@@connections ||= Hash.new do |hash, key|
|
14
|
+
hash[key] = case key
|
15
|
+
when :storage
|
16
|
+
Fog::Logger.warning("Dropbox[:storage] is not recommended, use Storage[:dropbox] for portability")
|
17
|
+
Fog::Storage.new(:provider => 'Dropbox')
|
18
|
+
else
|
19
|
+
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
@@connections[service]
|
23
|
+
end
|
24
|
+
|
25
|
+
def account
|
26
|
+
@@connections[:compute].account
|
27
|
+
end
|
28
|
+
|
29
|
+
def services
|
30
|
+
Fog::Dropbox.services
|
31
|
+
end
|
32
|
+
|
33
|
+
# based off of virtual_box.rb
|
34
|
+
def available?
|
35
|
+
# Make sure the gem we use is enabled.
|
36
|
+
availability = if Gem::Specification.respond_to?(:find_all_by_name)
|
37
|
+
!Gem::Specification.find_all_by_name('dropbox-sdk').empty? # newest rubygems
|
38
|
+
else
|
39
|
+
!Gem.source_index.find_name('dropbox-sdk').empty? # legacy
|
40
|
+
end
|
41
|
+
# Then make sure we have all of the requirements
|
42
|
+
for service in services
|
43
|
+
begin
|
44
|
+
service = self.class_for(service)
|
45
|
+
availability &&= service.requirements.all? { |requirement| Fog.credentials.include?(requirement) }
|
46
|
+
rescue ArgumentError => e
|
47
|
+
Fog::Logger.warning(e.message)
|
48
|
+
availability = false
|
49
|
+
rescue => e
|
50
|
+
availability = false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
if availability
|
55
|
+
for service in services
|
56
|
+
for collection in self.class_for(service).collections
|
57
|
+
unless self.respond_to?(collection)
|
58
|
+
self.class_eval <<-EOS, __FILE__, __LINE__
|
59
|
+
def self.#{collection}
|
60
|
+
self[:#{service}].#{collection}
|
61
|
+
end
|
62
|
+
EOS
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
availability
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/fog/dropbox.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/dropbox/models/storage/directory'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Storage
|
6
|
+
class Dropbox
|
7
|
+
class Directories < Fog::Collection
|
8
|
+
model Fog::Storage::Dropbox::Directory
|
9
|
+
|
10
|
+
def all
|
11
|
+
data = service.client.metadata('/')
|
12
|
+
load(data['contents'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(key, options = {})
|
16
|
+
data = service.client.metadata(key)
|
17
|
+
directory = new(data)
|
18
|
+
directory.files.load(data['contents'])
|
19
|
+
directory
|
20
|
+
rescue DropboxError
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
require 'fog/dropbox/models/storage/files'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Storage
|
6
|
+
class Dropbox
|
7
|
+
class Directory < Fog::Model
|
8
|
+
identity :key, :aliases => ['path']
|
9
|
+
|
10
|
+
attribute :size
|
11
|
+
attribute :rev
|
12
|
+
attribute :bytes
|
13
|
+
attribute :last_modified, :aliases => ['client_mtime']
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
requires :key
|
17
|
+
service.client.file_delete(key)
|
18
|
+
true
|
19
|
+
rescue DropboxError
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def files
|
24
|
+
@files ||= begin
|
25
|
+
Fog::Storage::Dropbox::Files.new(
|
26
|
+
:directory => self,
|
27
|
+
:service => service
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def save
|
33
|
+
requires :key
|
34
|
+
service.client.file_create_folder(key)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Storage
|
5
|
+
class Dropbox
|
6
|
+
class File < Fog::Model
|
7
|
+
identity :key, :aliases => 'path'
|
8
|
+
|
9
|
+
attribute :name
|
10
|
+
attribute :rev, :aliases => 'rev'
|
11
|
+
attribute :content_encoding, :aliases => 'Content-Encoding'
|
12
|
+
attribute :content_length, :aliases => ['size']
|
13
|
+
attribute :content_type, :aliases => 'mime_type'
|
14
|
+
attribute :last_modified, :aliases => ['client_mtime']
|
15
|
+
|
16
|
+
def body
|
17
|
+
attributes[:body] ||= if last_modified && (file = collection.get(identity))
|
18
|
+
service.client.get_file(key)
|
19
|
+
else
|
20
|
+
''
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def body=(new_body)
|
25
|
+
attributes[:body] = new_body
|
26
|
+
end
|
27
|
+
|
28
|
+
def directory
|
29
|
+
@directory
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy
|
33
|
+
requires :key
|
34
|
+
begin
|
35
|
+
service.client.file_delete(key)
|
36
|
+
rescue DropboxError
|
37
|
+
end
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
def save(options = {})
|
42
|
+
requires :body, :directory, :key
|
43
|
+
if body.is_a? String
|
44
|
+
service.client.put_file(key, body, true) # true means overwrite
|
45
|
+
else
|
46
|
+
local_file_size = Fog::Storage.get_body_size(body)
|
47
|
+
uploader = service.client.get_chunked_uploader(body, local_file_size)
|
48
|
+
retries = 0
|
49
|
+
chunk_size = 4 * (1024**2) # 4 MB
|
50
|
+
while uploader.offset < uploader.total_size
|
51
|
+
begin
|
52
|
+
uploader.upload(chunk_size)
|
53
|
+
rescue DropboxError => e
|
54
|
+
if retries > 10
|
55
|
+
break
|
56
|
+
end
|
57
|
+
retries += 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
uploader.finish(key, true) # true means overwrite
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def url()
|
65
|
+
requires :key
|
66
|
+
share = service.client.shares(key)
|
67
|
+
url = share['url']
|
68
|
+
r = Net::HTTP.get_response(URI.parse(url))
|
69
|
+
if r.code == "302"
|
70
|
+
url = r.header['location']
|
71
|
+
end
|
72
|
+
url.gsub "dl=0", "dl=1"
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|