dropbox_api 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGES.md +7 -0
- data/README.md +37 -12
- data/TODO.md +33 -3
- data/api_coverage.md +8 -6
- data/api_reference.md +25 -0
- data/lib/dropbox_api.rb +25 -1
- data/lib/dropbox_api/authenticator.rb +5 -9
- data/lib/dropbox_api/endpoints/base.rb +11 -0
- data/lib/dropbox_api/endpoints/files/get_thumbnail.rb +30 -6
- data/lib/dropbox_api/endpoints/files/upload.rb +18 -6
- data/lib/dropbox_api/endpoints/sharing/add_file_member.rb +60 -0
- data/lib/dropbox_api/endpoints/sharing/add_folder_member.rb +11 -8
- data/lib/dropbox_api/endpoints/sharing/list_folder_members.rb +16 -6
- data/lib/dropbox_api/endpoints/users/get_account_batch.rb +19 -0
- data/lib/dropbox_api/endpoints/users/get_current_account.rb +16 -0
- data/lib/dropbox_api/endpoints/users/get_space_usage.rb +16 -0
- data/lib/dropbox_api/errors/add_file_member_error.rb +6 -0
- data/lib/dropbox_api/errors/basic_error.rb +3 -0
- data/lib/dropbox_api/errors/file_member_action_error.rb +10 -0
- data/lib/dropbox_api/errors/sharing_file_access_error.rb +11 -0
- data/lib/dropbox_api/errors/too_many_requests_error.rb +19 -0
- data/lib/dropbox_api/metadata/access_level.rb +18 -0
- data/lib/dropbox_api/metadata/add_file_member_result.rb +19 -0
- data/lib/dropbox_api/metadata/add_member.rb +26 -54
- data/lib/dropbox_api/metadata/base.rb +53 -10
- data/lib/dropbox_api/metadata/basic_account.rb +19 -20
- data/lib/dropbox_api/metadata/deleted.rb +7 -8
- data/lib/dropbox_api/metadata/field.rb +3 -2
- data/lib/dropbox_api/metadata/file.rb +20 -17
- data/lib/dropbox_api/metadata/file_link.rb +26 -27
- data/lib/dropbox_api/metadata/file_member_action.rb +30 -0
- data/lib/dropbox_api/metadata/folder.rb +11 -8
- data/lib/dropbox_api/metadata/folder_sharing_info.rb +5 -6
- data/lib/dropbox_api/metadata/link_permissions.rb +9 -10
- data/lib/dropbox_api/metadata/member.rb +47 -0
- data/lib/dropbox_api/metadata/member_action_collection.rb +44 -0
- data/lib/dropbox_api/metadata/member_permission.rb +7 -0
- data/lib/dropbox_api/metadata/member_permission_list.rb +7 -0
- data/lib/dropbox_api/metadata/name.rb +7 -8
- data/lib/dropbox_api/metadata/parent_folder_access_info.rb +7 -0
- data/lib/dropbox_api/metadata/shared_folder.rb +14 -15
- data/lib/dropbox_api/metadata/shared_folder_policy.rb +5 -6
- data/lib/dropbox_api/metadata/space_allocation.rb +10 -0
- data/lib/dropbox_api/metadata/space_usage.rb +14 -0
- data/lib/dropbox_api/metadata/team_member_info.rb +9 -10
- data/lib/dropbox_api/result_builder.rb +1 -1
- data/lib/dropbox_api/results/add_file_member_result_list.rb +20 -0
- data/lib/dropbox_api/results/basic_account_batch.rb +7 -0
- data/lib/dropbox_api/version.rb +1 -1
- data/rails_setup.md +84 -0
- metadata +26 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd04df06e2b79e0a102c34ada12761d414d92484
|
4
|
+
data.tar.gz: 2d71c761e4b9c05e0207633d2b0d984f434ffd4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cfaf692c3c6625378951ddd42108e12d667477fb9468b5d1648e0891b7cb45cedd93fb7a06dd5e018625baf1955c330824dba14604569e323ceb0ea3aae5ba2
|
7
|
+
data.tar.gz: 26d60eb6ddfb03c8e3c8b3219d0b1698c4360215b5edbdb39d096f8c7adffa131dbf1e470cb8be911ca58e3322b143d18939e360017e4f4eda6e1a9e170e5331
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
- api_coverage.md api_reference.md rails_setup.md
|
data/CHANGES.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
This file aims to compile all the breaking changes introduced in each version.
|
2
|
+
|
3
|
+
### Version 0.2
|
4
|
+
|
5
|
+
- `list_folder_members` changed its signature from
|
6
|
+
`list_folder_members(folder_id, options = {})` to
|
7
|
+
`list_folder_members(folder_id, actions = [], options = {})`
|
data/README.md
CHANGED
@@ -40,6 +40,9 @@ DropboxApi::Client.new
|
|
40
40
|
#=> #<DropboxApi::Client ...>
|
41
41
|
```
|
42
42
|
|
43
|
+
Note that setting an ENV variable is only a feasible choice if you're only
|
44
|
+
using one account.
|
45
|
+
|
43
46
|
#### Option A: Get your access token from the website
|
44
47
|
|
45
48
|
The easiest way to obtain an access token is to get it from the Dropbox website.
|
@@ -54,17 +57,26 @@ to generate an access token.
|
|
54
57
|
|
55
58
|
You can obtain an authorization code with this library:
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
```ruby
|
61
|
+
authenticator = DropboxApi::Authenticator.new(CLIENT_ID, CLIENT_SECRET)
|
62
|
+
authenticator.authorize_url #=> "https://www.dropbox.com/..."
|
63
|
+
|
64
|
+
# Now you need to open the authorization URL in your browser,
|
65
|
+
# authorize the application and copy your code.
|
66
|
+
|
67
|
+
auth_bearer = authenticator.get_token(CODE) #=> #<OAuth2::AccessToken ...>`
|
68
|
+
auth_bearer.token #=> "VofXAX8D..."
|
69
|
+
# Keep this token, you'll need it to initialize a `DropboxApi::Client` object
|
70
|
+
```
|
71
|
+
|
72
|
+
#### Standard OAuth 2 flow
|
73
|
+
|
74
|
+
This is what many web applications will use. The process is described in
|
75
|
+
Dropbox's [OAuth guide](https://www.dropbox.com/developers/reference/oauth-guide#oauth-2-on-the-web).
|
64
76
|
|
65
|
-
|
77
|
+
If you have a Rails application, you might be interested in this [setup
|
78
|
+
guide](rails_setup.md).
|
66
79
|
|
67
|
-
Not implemented yet. :(
|
68
80
|
|
69
81
|
### Performing API calls
|
70
82
|
|
@@ -86,11 +98,18 @@ result.has_more?
|
|
86
98
|
#=> false
|
87
99
|
```
|
88
100
|
|
89
|
-
Refer to the
|
101
|
+
Refer to the
|
102
|
+
[documentation](http://www.rubydoc.info/gems/dropbox_api)
|
103
|
+
to see the details for each endpoint, you can find them all in the following
|
104
|
+
3 modules:
|
105
|
+
|
106
|
+
- [Files](http://www.rubydoc.info/gems/dropbox_api/DropboxApi/Endpoints/Files)
|
107
|
+
- [Sharing](http://www.rubydoc.info/gems/dropbox_api/DropboxApi/Endpoints/Sharing)
|
108
|
+
- [Users](http://www.rubydoc.info/gems/dropbox_api/DropboxApi/Endpoints/Users)
|
90
109
|
|
91
110
|
## Dependencies
|
92
111
|
|
93
|
-
###Network adapter
|
112
|
+
### Network adapter
|
94
113
|
|
95
114
|
This gem uses [faraday](https://github.com/lostisland/faraday#faraday).
|
96
115
|
So it should work on any network library.
|
@@ -109,7 +128,13 @@ commits and tags, and push the `.gem` file to
|
|
109
128
|
## Contributing
|
110
129
|
|
111
130
|
Any help will be much appreciated. It should be quite easy to implement most
|
112
|
-
of the [endpoints that are still pending](api_coverage.md)
|
131
|
+
of the [endpoints that are still pending](api_coverage.md) by looking at the
|
132
|
+
exising implementations (check out the `dropbox_api/endpoints` folder).
|
133
|
+
|
134
|
+
If you want to help but you're unsure how to get started, please get in touch
|
135
|
+
by opening an issue.
|
136
|
+
|
137
|
+
Here's the standard way to submit code updates:
|
113
138
|
|
114
139
|
1. Fork it ( https://github.com/Jesus/dropbox_api/fork )
|
115
140
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/TODO.md
CHANGED
@@ -1,8 +1,38 @@
|
|
1
|
-
#
|
1
|
+
# Week
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
TOKEN: VofXAX8DO1sAAAAAAAADiXbd__inZjFI0OTsK9ao8AAKmshXqdbnjOnXz7XylBbf
|
4
|
+
|
5
|
+
- add_file_member
|
6
|
+
- Refactor MemberActionCollection
|
7
|
+
- Implement DropboxApi::Metadata::Base#to_hash
|
8
|
+
|
9
|
+
- get_file_metadata
|
10
|
+
- get_folder_metadata
|
11
|
+
- get_shared_link_file
|
12
|
+
- get_shared_link_metadata
|
13
|
+
- list_shared_folders
|
14
|
+
- continue_list_shared_folders
|
15
|
+
- share_folder
|
16
|
+
- add_folder_member
|
17
|
+
- mount_folder
|
18
|
+
- list_folder_members
|
19
|
+
- relinquish_folder_membership
|
20
|
+
- transfer_folder
|
21
|
+
|
22
|
+
# Short term goals
|
23
|
+
|
24
|
+
- Remove dependency on faraday.
|
25
|
+
- Complete full [API coverage](api_coverage.md).
|
5
26
|
|
6
27
|
# Further on
|
7
28
|
|
29
|
+
- Improve the API reference page, help here:
|
30
|
+
http://gnuu.org/2009/11/18/customizing-yard-templates/
|
8
31
|
- Supporting streams would be great.
|
32
|
+
- Add a layer to handle pagination, use `Enumerable`.
|
33
|
+
|
34
|
+
# Release guide
|
35
|
+
|
36
|
+
1. Bump version in `version.rb`.
|
37
|
+
2. Create tag and write release notes in Github.com.
|
38
|
+
3.
|
data/api_coverage.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# @title API Implementation Coverage
|
2
|
+
|
1
3
|
**IMPORTANT: This document is work in progress. Information isn't accurate.**
|
2
4
|
|
3
5
|
The Dropbox API changes frequently, so you may find out that the feature that
|
@@ -38,7 +40,7 @@ API call | Status
|
|
38
40
|
`/save_url` | 🌑
|
39
41
|
`/save_url/check_job_status` | 🌑
|
40
42
|
`/search` | 🌕
|
41
|
-
`/upload` |
|
43
|
+
`/upload` | 🌔
|
42
44
|
`/upload_session/append` | 🌑
|
43
45
|
`/upload_session/append_v2` | 🌑
|
44
46
|
`/upload_session/finish` | 🌑
|
@@ -49,7 +51,7 @@ API call | Status
|
|
49
51
|
## Sharing namespace
|
50
52
|
API call | Status
|
51
53
|
--- | :---:
|
52
|
-
`/add_file_member` |
|
54
|
+
`/add_file_member` | 🌔
|
53
55
|
`/add_folder_member` | 🌕
|
54
56
|
`/change_file_member_access` | 🌑
|
55
57
|
`/check_job_status` | 🌑
|
@@ -66,7 +68,7 @@ API call | Status
|
|
66
68
|
`/list_file_members` | 🌑
|
67
69
|
`/list_file_members/batch` | 🌑
|
68
70
|
`/list_file_members/continue` | 🌑
|
69
|
-
`/list_folder_members` |
|
71
|
+
`/list_folder_members` | 🌕
|
70
72
|
`/list_folder_members/continue` | 🌑
|
71
73
|
`/list_folders` | 🌑
|
72
74
|
`/list_folders/continue` | 🌑
|
@@ -96,9 +98,9 @@ API call | Status
|
|
96
98
|
API call | Status
|
97
99
|
--- | :---:
|
98
100
|
`/get_account` | 🌕
|
99
|
-
`/get_account_batch` |
|
100
|
-
`/get_current_account` |
|
101
|
-
`/get_space_usage` |
|
101
|
+
`/get_account_batch` | 🌕
|
102
|
+
`/get_current_account` | 🌕
|
103
|
+
`/get_space_usage` | 🌕
|
102
104
|
|
103
105
|
|
104
106
|
## Dropbox Business API
|
data/api_reference.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# @title API Reference
|
2
|
+
|
3
|
+
{render:DropboxApi::Endpoints::Files::Copy#copy}
|
4
|
+
{render:DropboxApi::Endpoints::Files::CreateFolder#create_folder}
|
5
|
+
{render:DropboxApi::Endpoints::Files::Delete#delete}
|
6
|
+
{render:DropboxApi::Endpoints::Files::Download#download}
|
7
|
+
{render:DropboxApi::Endpoints::Files::GetMetadata#get_metadata}
|
8
|
+
{render:DropboxApi::Endpoints::Files::GetPreview#get_preview}
|
9
|
+
{render:DropboxApi::Endpoints::Files::GetTemporaryLink#get_temporary_link}
|
10
|
+
{render:DropboxApi::Endpoints::Files::GetThumbnail#get_thumbnail}
|
11
|
+
{render:DropboxApi::Endpoints::Files::ListFolder#list_folder}
|
12
|
+
{render:DropboxApi::Endpoints::Files::ListFolderContinue#list_folder_continue}
|
13
|
+
{render:DropboxApi::Endpoints::Files::ListFolderGetLatestCursor#list_folder_get_latest_cursor}
|
14
|
+
{render:DropboxApi::Endpoints::Files::ListFolderLongpoll#list_folder_longpoll}
|
15
|
+
{render:DropboxApi::Endpoints::Files::ListRevisions#list_revisions}
|
16
|
+
{render:DropboxApi::Endpoints::Files::Move#move}
|
17
|
+
{render:DropboxApi::Endpoints::Files::Restore#restore}
|
18
|
+
{render:DropboxApi::Endpoints::Files::Search#search}
|
19
|
+
{render:DropboxApi::Endpoints::Files::Upload#upload}
|
20
|
+
|
21
|
+
{render:DropboxApi::Endpoints::Sharing::AddFolderMember#add_folder_member}
|
22
|
+
{render:DropboxApi::Endpoints::Sharing::CreateSharedLinkWithSettings#create_shared_link_with_settings}
|
23
|
+
{render:DropboxApi::Endpoints::Sharing::ListFolderMembers#list_folder_members}
|
24
|
+
{render:DropboxApi::Endpoints::Sharing::ListSharedLinks#list_shared_links}
|
25
|
+
{render:DropboxApi::Endpoints::Sharing::ShareFolder#share_folder}
|
data/lib/dropbox_api.rb
CHANGED
@@ -1,16 +1,28 @@
|
|
1
1
|
require 'dropbox_api/version'
|
2
2
|
|
3
|
+
require 'time'
|
3
4
|
require 'json'
|
4
5
|
require 'faraday'
|
5
6
|
|
7
|
+
require 'dropbox_api/authenticator'
|
8
|
+
|
6
9
|
require 'dropbox_api/middleware/decode_result'
|
7
10
|
|
8
11
|
require 'dropbox_api/metadata/field'
|
9
|
-
require 'dropbox_api/metadata/add_member'
|
10
12
|
require 'dropbox_api/metadata/base'
|
13
|
+
|
14
|
+
require 'dropbox_api/metadata/access_level'
|
15
|
+
require 'dropbox_api/metadata/member'
|
16
|
+
require 'dropbox_api/metadata/add_member'
|
11
17
|
require 'dropbox_api/metadata/name'
|
18
|
+
require 'dropbox_api/metadata/file_member_action'
|
19
|
+
require 'dropbox_api/metadata/member_permission'
|
20
|
+
require 'dropbox_api/metadata/member_permission_list'
|
21
|
+
require 'dropbox_api/metadata/add_file_member_result'
|
22
|
+
require 'dropbox_api/metadata/parent_folder_access_info'
|
12
23
|
require 'dropbox_api/metadata/basic_account'
|
13
24
|
require 'dropbox_api/metadata/link_permissions'
|
25
|
+
require 'dropbox_api/metadata/member_action_collection'
|
14
26
|
require 'dropbox_api/metadata/team'
|
15
27
|
require 'dropbox_api/metadata/team_member_info'
|
16
28
|
require 'dropbox_api/metadata/file'
|
@@ -23,6 +35,8 @@ require 'dropbox_api/metadata/shared_folder'
|
|
23
35
|
require 'dropbox_api/metadata/file_link'
|
24
36
|
require 'dropbox_api/metadata/folder_link'
|
25
37
|
require 'dropbox_api/metadata/shared_link'
|
38
|
+
require 'dropbox_api/metadata/space_allocation'
|
39
|
+
require 'dropbox_api/metadata/space_usage'
|
26
40
|
|
27
41
|
require 'dropbox_api/errors/http_error'
|
28
42
|
require 'dropbox_api/errors/basic_error'
|
@@ -40,6 +54,8 @@ require 'dropbox_api/errors/create_folder_error'
|
|
40
54
|
require 'dropbox_api/errors/create_shared_link_with_settings_error'
|
41
55
|
require 'dropbox_api/errors/delete_error'
|
42
56
|
require 'dropbox_api/errors/download_error'
|
57
|
+
require 'dropbox_api/errors/sharing_file_access_error'
|
58
|
+
require 'dropbox_api/errors/file_member_action_error'
|
43
59
|
require 'dropbox_api/errors/get_metadata_error'
|
44
60
|
require 'dropbox_api/errors/list_folder_error'
|
45
61
|
require 'dropbox_api/errors/list_revisions_error'
|
@@ -51,11 +67,15 @@ require 'dropbox_api/errors/add_member_selector_error'
|
|
51
67
|
require 'dropbox_api/errors/shared_folder_access_error'
|
52
68
|
require 'dropbox_api/errors/upload_write_failed_error'
|
53
69
|
require 'dropbox_api/errors/upload_error'
|
70
|
+
require 'dropbox_api/errors/add_file_member_error'
|
54
71
|
require 'dropbox_api/errors/add_folder_member_error'
|
72
|
+
require 'dropbox_api/errors/too_many_requests_error'
|
55
73
|
require 'dropbox_api/errors/get_account_error'
|
56
74
|
|
57
75
|
require 'dropbox_api/result_builder'
|
58
76
|
require 'dropbox_api/results/base'
|
77
|
+
require 'dropbox_api/results/basic_account_batch'
|
78
|
+
require 'dropbox_api/results/add_file_member_result_list'
|
59
79
|
require 'dropbox_api/results/get_temporary_link_result'
|
60
80
|
require 'dropbox_api/results/list_folder_result'
|
61
81
|
require 'dropbox_api/results/list_revisions_result'
|
@@ -94,9 +114,13 @@ require 'dropbox_api/endpoints/files/move'
|
|
94
114
|
require 'dropbox_api/endpoints/files/restore'
|
95
115
|
require 'dropbox_api/endpoints/files/search'
|
96
116
|
require 'dropbox_api/endpoints/files/upload'
|
117
|
+
require 'dropbox_api/endpoints/sharing/add_file_member'
|
97
118
|
require 'dropbox_api/endpoints/sharing/add_folder_member'
|
98
119
|
require 'dropbox_api/endpoints/sharing/list_folder_members'
|
99
120
|
require 'dropbox_api/endpoints/sharing/share_folder'
|
100
121
|
require 'dropbox_api/endpoints/sharing/list_shared_links'
|
101
122
|
require 'dropbox_api/endpoints/sharing/create_shared_link_with_settings'
|
102
123
|
require 'dropbox_api/endpoints/users/get_account'
|
124
|
+
require 'dropbox_api/endpoints/users/get_account_batch'
|
125
|
+
require 'dropbox_api/endpoints/users/get_current_account'
|
126
|
+
require 'dropbox_api/endpoints/users/get_space_usage'
|
@@ -2,19 +2,15 @@ require 'oauth2'
|
|
2
2
|
|
3
3
|
module DropboxApi
|
4
4
|
class Authenticator < OAuth2::Client
|
5
|
+
extend Forwardable
|
6
|
+
|
5
7
|
def initialize(client_id, client_secret)
|
6
|
-
@
|
8
|
+
@auth_code = OAuth2::Client.new(client_id, client_secret, {
|
7
9
|
:authorize_url => 'https://www.dropbox.com/1/oauth2/authorize',
|
8
10
|
:token_url => 'https://api.dropboxapi.com/1/oauth2/token'
|
9
|
-
})
|
10
|
-
end
|
11
|
-
|
12
|
-
def authorize_url
|
13
|
-
@oauth_client.auth_code.authorize_url
|
11
|
+
}).auth_code
|
14
12
|
end
|
15
13
|
|
16
|
-
|
17
|
-
@oauth_client.auth_code.get_token oauth_code
|
18
|
-
end
|
14
|
+
def_delegators :@auth_code, :authorize_url, :get_token
|
19
15
|
end
|
20
16
|
end
|
@@ -16,11 +16,22 @@ module DropboxApi::Endpoints
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def process_response(raw_response)
|
19
|
+
# Official Dropbox documentation for HTTP error codes:
|
20
|
+
# https://www.dropbox.com/developers/documentation/http/documentation#error-handling
|
19
21
|
case raw_response.status
|
20
22
|
when 200, 409
|
21
23
|
# Status code 409 is "Endpoint-specific error". We need to look at
|
22
24
|
# the response body to build an exception.
|
23
25
|
build_result(raw_response.env[:api_result])
|
26
|
+
when 429
|
27
|
+
error = DropboxApi::Errors::TooManyRequestsError.build(
|
28
|
+
raw_response.env[:api_result]["error_summary"],
|
29
|
+
raw_response.env[:api_result]["error"]["reason"]
|
30
|
+
)
|
31
|
+
|
32
|
+
error.retry_after = raw_response.headers["retry-after"].to_i
|
33
|
+
|
34
|
+
raise error
|
24
35
|
else
|
25
36
|
raise DropboxApi::Errors::HttpError,
|
26
37
|
"HTTP #{raw_response.status}: #{raw_response.body}"
|
@@ -14,13 +14,37 @@ module DropboxApi::Endpoints::Files
|
|
14
14
|
# jpg, jpeg, png, tiff, tif, gif and bmp. Photos that are larger than 20MB
|
15
15
|
# in size won't be converted to a thumbnail.
|
16
16
|
#
|
17
|
+
# @example
|
18
|
+
# # Save thumbnail to a local file
|
19
|
+
# client = DropboxApi::Client.new
|
20
|
+
# file = File.open("thumbnail.png", "w")
|
21
|
+
# client.get_thumbnail "/dropbox_image.png" do |thumbnail_content|
|
22
|
+
# file.write thumbnail_content
|
23
|
+
# end
|
24
|
+
# file.close
|
25
|
+
# @example
|
26
|
+
# # Save thumbnail to a local file with .jpg format
|
27
|
+
# client = DropboxApi::Client.new
|
28
|
+
# file = File.open("thumbnail.jpg", "w")
|
29
|
+
# client.get_thumbnail("/dropbox_image.png", :format => :jpeg) do |thumbnail_content|
|
30
|
+
# file.write thumbnail_content
|
31
|
+
# end
|
32
|
+
# file.close
|
33
|
+
# @example
|
34
|
+
# # Upload thumbnail to Amazon S3 (assuming you're using their SDK)
|
35
|
+
# s3_object = AWS::S3.new.s3.buckets['my-bucket'].objects['key']
|
36
|
+
# #=> <AWS::S3::S3Object ...>
|
37
|
+
# client = DropboxApi::Client.new
|
38
|
+
# client.get_thumbnail "/dropbox_image.png" do |thumbnail_content|
|
39
|
+
# s3_object.write thumbnail_content
|
40
|
+
# end
|
17
41
|
# @param path [String] The path to the image file you want to thumbnail.
|
18
|
-
# @option format [:jpeg, :png] The format for the thumbnail image,
|
19
|
-
# (default) or png
|
20
|
-
# while png is better for screenshots and digital arts. The
|
21
|
-
#
|
22
|
-
# @option size [:w32h32, :w64h64, :w128h128, :w640h480, :w1024h768]
|
23
|
-
# size for the thumbnail image. The default is
|
42
|
+
# @option options format [:jpeg, :png] The format for the thumbnail image,
|
43
|
+
# +:jpeg+ (default) or +:png+. For images that are photos, +:jpeg+ should be
|
44
|
+
# preferred, while png is better for screenshots and digital arts. The
|
45
|
+
# default is +:jpeg+.
|
46
|
+
# @option options size [:w32h32, :w64h64, :w128h128, :w640h480, :w1024h768]
|
47
|
+
# The size for the thumbnail image. The default is +:w64h64+.
|
24
48
|
add_endpoint :get_thumbnail do |path, options = {}, &block|
|
25
49
|
validate_options([:format, :size], options)
|
26
50
|
options[:format] ||= :jpeg
|
@@ -5,16 +5,28 @@ module DropboxApi::Endpoints::Files
|
|
5
5
|
ResultType = DropboxApi::Metadata::File
|
6
6
|
ErrorType = DropboxApi::Errors::UploadError
|
7
7
|
|
8
|
-
# @method upload(path)
|
9
|
-
#
|
8
|
+
# @method upload(path, content, options = {})
|
9
|
+
# Creates a new file.
|
10
|
+
#
|
10
11
|
# Do not use this to upload a file larger than 150 MB. Instead, create an
|
11
12
|
# upload session with #upload_session_start().
|
12
13
|
#
|
14
|
+
# @example
|
15
|
+
# client = DropboxApi::Client.new
|
16
|
+
# file_content = IO.read "local_image.png"
|
17
|
+
# client.upload "/image.png", file_content
|
18
|
+
# #=> #<DropboxApi::Metadata::File: @name="image.png" ...>
|
19
|
+
# @example
|
20
|
+
# client = DropboxApi::Client.new
|
21
|
+
# client.upload "/file.txt", "Contents of a plain text file."
|
22
|
+
# #=> #<DropboxApi::Metadata::File: @name="file.txt" ...>
|
13
23
|
# @param path [String] Path in the user's Dropbox to save the file.
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
24
|
+
# @param content The contents of the file that will be uploaded. This
|
25
|
+
# could be the result of the +IO::read+ method.
|
26
|
+
# @option options autorename [Boolean] If there's a conflict, as
|
27
|
+
# determined by mode, have the Dropbox server try to autorename the
|
28
|
+
# file to avoid conflict. The default for this field is False.
|
29
|
+
# @option options mute [Boolean] Normally, users are made aware of any file
|
18
30
|
# modifications in their Dropbox account via notifications in the client
|
19
31
|
# software. If true, this tells the clients that this modification
|
20
32
|
# shouldn't result in a user notification. The default for this field is
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module DropboxApi::Endpoints::Sharing
|
2
|
+
class AddFileMember < DropboxApi::Endpoints::Rpc
|
3
|
+
Method = :post
|
4
|
+
Path = "/2/sharing/add_file_member".freeze
|
5
|
+
ResultType = DropboxApi::Results::AddFileMemberResultList
|
6
|
+
ErrorType = DropboxApi::Errors::AddFileMemberError
|
7
|
+
|
8
|
+
include DropboxApi::Endpoints::OptionsValidator
|
9
|
+
|
10
|
+
# @method add_file_member(file, members, options = {})
|
11
|
+
# Adds specified members to a file.
|
12
|
+
#
|
13
|
+
# The +members+ parameter must be an Array. Each item in the array could
|
14
|
+
# be either a String or a {Metadata::Member} object, which allows more
|
15
|
+
# advanced options.
|
16
|
+
#
|
17
|
+
# @param file [String] File to which to add members. It can be a path or
|
18
|
+
# an ID such as +id:3kmLmQFnf1AAAAAAAAAAAw+.
|
19
|
+
# @param members [Array<Member,String>] Members to add. Note that even
|
20
|
+
# an email address is given, this may result in a user being directy
|
21
|
+
# added to the membership if that email is the user's main account email.
|
22
|
+
# @option options quiet [Boolean] Whether added members should be notified
|
23
|
+
# via email and device notifications of their invite. The default for
|
24
|
+
# this field is +false+.
|
25
|
+
# @option options custom_message [String] Message to send to added members
|
26
|
+
# in their invitation. This field is optional.
|
27
|
+
# @option options access_level [AccessLevel] AccessLevel union object,
|
28
|
+
# describing what access level we want to give new members. The default
|
29
|
+
# for this is +:viewer+.
|
30
|
+
# @option options add_message_as_comment [String] Optional message to
|
31
|
+
# display to added members in their invitation. This field is optional.
|
32
|
+
add_endpoint :add_file_member do |file, members, options = {}|
|
33
|
+
validate_options([:quiet, :custom_message], options)
|
34
|
+
options[:quiet] ||= false
|
35
|
+
options[:custom_message] ||= nil
|
36
|
+
options[:access_level] ||= :viewer
|
37
|
+
options[:add_message_as_comment] ||= false
|
38
|
+
|
39
|
+
perform_request options.merge({
|
40
|
+
:file => file,
|
41
|
+
:members => build_members_param(members)
|
42
|
+
})
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def build_members_param(members)
|
48
|
+
members.map do |member|
|
49
|
+
case member
|
50
|
+
when String
|
51
|
+
DropboxApi::Metadata::Member.build_from_email_or_dropbox_id member
|
52
|
+
when DropboxApi::Metadata::Member
|
53
|
+
member
|
54
|
+
else
|
55
|
+
raise ArgumentError, "Invalid argument type `#{member.class.name}`"
|
56
|
+
end
|
57
|
+
end.map(&:to_hash)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|