brick_ftp 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bff0644f7601a0b205787a383d7e404ea52575f6e10d2e4ec92f2494b0b2e207
4
- data.tar.gz: 89b62baafda83fc5a354a3b869bdb9779ec0ff82def20627f40412ef02f2818e
3
+ metadata.gz: 5a0069f587ef3fe9093bac0c8226af17eecc3634cb461bee69b2de18748b6b1f
4
+ data.tar.gz: 31a6d9bb6e85cfe8fec3f246c97bc38632b42fdd1a3f6191f09f4e82948c89a7
5
5
  SHA512:
6
- metadata.gz: '08e939656344e02093ac1df11a0fd9f93194706eac4de105880f90177c7d67876af69cfd42694fe9260e38b4599f89a61ceb6b4ed106ef1d903c68848b20f961'
7
- data.tar.gz: f441cbcf2c4e2bb5c64fecb88c2e44ec5bd3293ee6d9fc2bd77b3715635fcb707bd61e3e601e38d048c32d2c6706bcff711d418eab1610c0dbebe7264464c562
6
+ metadata.gz: 3ccbfa02cab23edd32e91400fc5bc3fc1a0ec75dbe9e763024249c7271d78abede39074994fe1bae73e613f7f09f6c44761bb392f16bb8d1ff92831e0da4d98d
7
+ data.tar.gz: 68cd755ff67fcb37d21ca17743d2df51ceceebbf54f0afb24d38459f92c848df4b8043db36345a47376107224a0f94473dbbdfc6fc2df5e43b4d47e382d7a21d
data/CHANGELOG.md CHANGED
@@ -2,10 +2,10 @@ Changelog
2
2
  ====
3
3
 
4
4
 
5
- [unreleased](https://github.com/koshigoe/brick_ftp/compare/v0.7.0...master)
5
+ [unreleased](https://github.com/koshigoe/brick_ftp/compare/v0.7.1...master)
6
6
  ----
7
7
 
8
- [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.7.0...master)
8
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.7.1...master)
9
9
 
10
10
  ### Enhancements:
11
11
 
@@ -14,6 +14,20 @@ Changelog
14
14
  ### Breaking Changes:
15
15
 
16
16
 
17
+ [v0.7.1](https://github.com/koshigoe/brick_ftp/compare/v0.7.0...v0.7.1)
18
+ ----
19
+
20
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.7.0...v0.7.1)
21
+
22
+ ### Enhancements:
23
+
24
+ - [#89](https://github.com/koshigoe/brick_ftp/pull/89) [Experimental] Allow to execute each steps of multi part uploading.
25
+
26
+ ### Fixed Bugs:
27
+
28
+ ### Breaking Changes:
29
+
30
+
17
31
  [v0.7.0](https://github.com/koshigoe/brick_ftp/compare/v0.6.1...v0.7.0)
18
32
  ----
19
33
 
data/lib/brick_ftp.rb CHANGED
@@ -33,6 +33,8 @@ require 'brick_ftp/api/file_operation'
33
33
  require 'brick_ftp/api/file_operation/move'
34
34
  require 'brick_ftp/api/file_operation/copy'
35
35
  require 'brick_ftp/api/file_operation/upload'
36
+ require 'brick_ftp/api/file_operation/uploading_session'
37
+ require 'brick_ftp/api/file_operation/uploading_result'
36
38
  require 'brick_ftp/api/site_usage'
37
39
  require 'brick_ftp/webhook'
38
40
  require 'brick_ftp/webhook/request'
@@ -0,0 +1,22 @@
1
+ module BrickFTP
2
+ module API
3
+ module FileOperation
4
+ class UploadingResult < BrickFTP::API::Base
5
+ endpoint :post, :create, '/api/rest/v1/files/%{path}'
6
+
7
+ attribute :path
8
+ attribute :type
9
+ attribute :size
10
+ attribute :mtime
11
+ attribute :crc32
12
+ attribute :md5
13
+
14
+ def self.create(path:, ref:)
15
+ api_client = BrickFTP::HTTPClient.new
16
+ res = api_client.post(api_path_for(:create, path: path), params: { action: 'end', ref: ref })
17
+ new(res.symbolize_keys)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,85 @@
1
+ module BrickFTP
2
+ module API
3
+ module FileOperation
4
+ class UploadingSession < BrickFTP::API::Base
5
+ include Enumerable
6
+
7
+ endpoint :post, :create, '/api/rest/v1/files/%{path}'
8
+
9
+ attribute :ref
10
+ attribute :http_method
11
+ attribute :upload_uri
12
+ attribute :partsize
13
+ attribute :part_number
14
+ attribute :available_parts
15
+ attribute :headers
16
+ attribute :parameters
17
+ attribute :send
18
+ attribute :path
19
+ attribute :action
20
+ attribute :ask_about_overwrites
21
+ attribute :expires
22
+ attribute :next_partsize
23
+ attribute :provided_mtime
24
+ attribute :permission
25
+
26
+ # Get uploading URL.
27
+ #
28
+ # @see https://brickftp.com/docs/rest-api/file-uploading/
29
+ # @param [String] path Remote file path.
30
+ # @return [BrickFTP::API::FileOperation::UploadingSession] A session object of uploading file.
31
+ #
32
+ def self.create(path:)
33
+ api_client = BrickFTP::HTTPClient.new
34
+ res = api_client.post(api_path_for(:create, path: path), params: { action: 'put' })
35
+ new(res.symbolize_keys)
36
+ end
37
+
38
+ # Upload data.
39
+ #
40
+ # @param [String] upload_uri A uplading URL.
41
+ # @param [IO] data An IO object to upload.
42
+ #
43
+ def self.upload(upload_uri:, data:)
44
+ uri = URI.parse(upload_uri)
45
+ upload_client = BrickFTP::HTTPClient.new(uri.host)
46
+ upload_client.put(uri.to_s, params: data)
47
+ end
48
+
49
+ # Get uploading URL for multi part uploading.
50
+ #
51
+ # @param [Integer] part_number The part number.
52
+ # @return [BrickFTP::API::FileOperation::UploadingSession] A session object of uploading file.
53
+ #
54
+ def at(part_number)
55
+ params = { action: 'put', ref: ref, part: part_number }
56
+ api_client = BrickFTP::HTTPClient.new
57
+ res = api_client.post(self.class.api_path_for(:create, path: path), params: params)
58
+ self.class.new(res.symbolize_keys)
59
+ end
60
+
61
+ # Get each uploading URLs.
62
+ #
63
+ # @yield [session] Gives uploading session object to the block.
64
+ # @yieldparam [BrickFTP::API::FileOperation::UploadingSession] session A session object of uploading file.
65
+ #
66
+ def each
67
+ return enum_for(__method__) unless block_given?
68
+
69
+ yield self
70
+ (part_number + 1).upto(available_parts) do |n|
71
+ yield at(n)
72
+ end
73
+ end
74
+
75
+ # Complete uploading file.
76
+ #
77
+ # @return [BrickFTP::API::FileOperation::UploadingResult] A result of uploading file.
78
+ #
79
+ def commit
80
+ UploadingResult.create(path: path, ref: ref)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,3 +1,3 @@
1
1
  module BrickFTP
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.7.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick_ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - koshigoe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-18 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -202,6 +202,8 @@ files:
202
202
  - lib/brick_ftp/api/file_operation/copy.rb
203
203
  - lib/brick_ftp/api/file_operation/move.rb
204
204
  - lib/brick_ftp/api/file_operation/upload.rb
205
+ - lib/brick_ftp/api/file_operation/uploading_result.rb
206
+ - lib/brick_ftp/api/file_operation/uploading_session.rb
205
207
  - lib/brick_ftp/api/folder.rb
206
208
  - lib/brick_ftp/api/folder_behavior.rb
207
209
  - lib/brick_ftp/api/group.rb