fastlane-plugin-dropbox 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/fastlane/plugin/dropbox/actions/dropbox_action.rb +66 -16
- data/lib/fastlane/plugin/dropbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c56b82a82ac14332f51d316963e2d754f953d5f
|
4
|
+
data.tar.gz: 2e6873044edb0257de75a9f8c43ff6d9f01888ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ad412c087e911833ff72a285e3814b79802243ff06aa277d8866a3a44859408691d3f3723ea1719884488e9969cdb48424a862e2ecdd471fa5025137ce7276b
|
7
|
+
data.tar.gz: e370924eccc4c93bb911bcb33786a5088d379d38a83bdb474c361aa092eccb03063eb5ed49af6dc382647d4ee072d2b5abbc7d1f5d5df2bf82341550f587b5db
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Fastlane Dropbox plugin
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/fastlane-plugin-dropbox)
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-dropbox) [](https://badge.fury.io/rb/fastlane-plugin-dropbox)
|
4
4
|
|
5
5
|
## Getting Started
|
6
6
|
|
@@ -29,6 +29,8 @@ In order to register a Dropbox app you need to go to [Dropbox Developers](https:
|
|
29
29
|
dropbox(
|
30
30
|
file_path: '/some/local-path/to/file.txt',
|
31
31
|
dropbox_path: '/path/to/Dropbox/destination/folder',
|
32
|
+
write_mode: "update",
|
33
|
+
update_rev: "file-revision-to-update",
|
32
34
|
app_key: 'your-dropbox-app-key',
|
33
35
|
app_secret: 'your-dropbox-app-secret'
|
34
36
|
)
|
@@ -13,6 +13,22 @@ module Fastlane
|
|
13
13
|
|
14
14
|
params[:keychain] ||= default_keychain
|
15
15
|
|
16
|
+
write_mode =
|
17
|
+
if params[:write_mode].nil?
|
18
|
+
'add'
|
19
|
+
elsif params[:write_mode].eql? 'update'
|
20
|
+
if params[:update_rev].nil?
|
21
|
+
UI.user_error! 'You need to specify `update_rev` when using `update` write_mode.'
|
22
|
+
else
|
23
|
+
DropboxApi::Metadata::WriteMode.new({
|
24
|
+
'.tag' => 'update',
|
25
|
+
'update' => params[:update_rev]
|
26
|
+
})
|
27
|
+
end
|
28
|
+
else
|
29
|
+
params[:write_mode]
|
30
|
+
end
|
31
|
+
|
16
32
|
access_token = get_token_from_keychain(params[:keychain], params[:keychain_password])
|
17
33
|
unless access_token
|
18
34
|
access_token = request_token(params[:app_key], params[:app_secret])
|
@@ -23,36 +39,52 @@ module Fastlane
|
|
23
39
|
|
24
40
|
client = DropboxApi::Client.new(access_token)
|
25
41
|
|
26
|
-
|
42
|
+
output_file = nil
|
27
43
|
|
28
44
|
chunk_size = 157_286_400 # 150 megabytes
|
29
45
|
|
30
46
|
if File.size(params[:file_path]) < chunk_size
|
31
|
-
|
32
|
-
output_file_name = file.name
|
47
|
+
output_file = upload(client, params[:file_path], destination_path(params), write_mode)
|
33
48
|
else
|
34
|
-
|
49
|
+
output_file = upload_chunked(client, chunk_size, params[:file_path], destination_path(params), write_mode)
|
50
|
+
end
|
35
51
|
|
36
|
-
|
37
|
-
UI.
|
38
|
-
|
52
|
+
if output_file.name != File.basename(params[:file_path])
|
53
|
+
UI.user_error! 'Failed to upload file to Dropbox'
|
54
|
+
else
|
55
|
+
UI.success "File revision: '#{output_file.rev}'"
|
56
|
+
UI.success "Successfully uploaded file to Dropbox at '#{destination_path(params)}'"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.upload(client, file_path, destination_path, write_mode)
|
61
|
+
begin
|
62
|
+
client.upload destination_path, File.read(file_path), mode: write_mode
|
63
|
+
rescue DropboxApi::Errors::UploadWriteFailedError => e
|
64
|
+
UI.user_error! "Failed to upload file to Dropbox. Error message returned by Dropbox API: \"#{e.message}\""
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.upload_chunked(client, chunk_size, file_path, destination_path, write_mode)
|
69
|
+
parts = chunker file_path, './part', chunk_size
|
70
|
+
UI.message ''
|
71
|
+
UI.important "The archive is a big file so we're uploading it in 150MB chunks"
|
72
|
+
UI.message ''
|
39
73
|
|
74
|
+
begin
|
40
75
|
UI.message "Uploading part #1 (#{File.size(parts[0])} bytes)..."
|
41
76
|
cursor = client.upload_session_start File.read(parts[0])
|
42
77
|
parts[1..parts.size].each_with_index do |part, index|
|
43
78
|
UI.message "Uploading part ##{index + 2} (#{File.size(part)} bytes)..."
|
44
79
|
client.upload_session_append_v2 cursor, File.read(part)
|
45
80
|
end
|
46
|
-
file = client.upload_session_finish cursor, DropboxApi::Metadata::CommitInfo.new('path' => destination_path(params),
|
47
|
-
'mode' => :add)
|
48
|
-
output_file_name = file.name
|
49
|
-
parts.each { |part| File.delete(part) }
|
50
|
-
end
|
51
81
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
UI.
|
82
|
+
client.upload_session_finish cursor, DropboxApi::Metadata::CommitInfo.new('path' => destination_path,
|
83
|
+
'mode' => write_mode)
|
84
|
+
rescue DropboxApi::Errors::UploadWriteFailedError => e
|
85
|
+
UI.user_error! "Error uploading file to Dropbox: \"#{e.message}\""
|
86
|
+
ensure
|
87
|
+
parts.each { |part| File.delete(part) }
|
56
88
|
end
|
57
89
|
end
|
58
90
|
|
@@ -148,6 +180,22 @@ module Fastlane
|
|
148
180
|
description: 'Path to the destination Dropbox folder',
|
149
181
|
type: String,
|
150
182
|
optional: true),
|
183
|
+
FastlaneCore::ConfigItem.new(key: :write_mode,
|
184
|
+
env_name: 'DROPBOX_WRITE_MODE',
|
185
|
+
description: 'Determines uploaded file write mode. Supports `add`, `overwrite` and `update`',
|
186
|
+
type: String,
|
187
|
+
optional: true,
|
188
|
+
verify_block: proc do |value|
|
189
|
+
UI.command_output("write_mode '#{value}' not recognized. Defaulting to `add`.") unless value =~ /(add|overwrite|update)/
|
190
|
+
end),
|
191
|
+
FastlaneCore::ConfigItem.new(key: :update_rev,
|
192
|
+
env_name: 'DROPBOX_UPDATE_REV',
|
193
|
+
description: 'Revision of the file uploaded in `update` write_mode',
|
194
|
+
type: String,
|
195
|
+
optional: true,
|
196
|
+
verify_block: proc do |value|
|
197
|
+
UI.user_error!("Revision no. must be at least 9 hexadecimal characters ([0-9a-f]).") unless value =~ /[0-9a-f]{9,}/
|
198
|
+
end),
|
151
199
|
FastlaneCore::ConfigItem.new(key: :app_key,
|
152
200
|
env_name: 'DROPBOX_APP_KEY',
|
153
201
|
description: 'App Key of your Dropbox app',
|
@@ -195,6 +243,8 @@ module Fastlane
|
|
195
243
|
'dropbox(
|
196
244
|
file_path: "./path/to/file.txt",
|
197
245
|
dropbox_path: "/My Dropbox Folder/Text files",
|
246
|
+
write_mode: "add/overwrite/update",
|
247
|
+
update_rev: "a1c10ce0dd78",
|
198
248
|
app_key: "dropbox-app-key",
|
199
249
|
app_secret: "dropbox-app-secret"
|
200
250
|
)'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-dropbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Kapusta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox_api
|