uplink-ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/uplink/access.rb +119 -0
- data/lib/uplink/bucket.rb +47 -0
- data/lib/uplink/download.rb +42 -0
- data/lib/uplink/edge_credential.rb +36 -0
- data/lib/uplink/error_util.rb +23 -0
- data/lib/uplink/object.rb +49 -0
- data/lib/uplink/project.rb +259 -0
- data/lib/uplink/storj_error.rb +66 -0
- data/lib/uplink/uplink_util.rb +80 -0
- data/lib/uplink/upload.rb +208 -0
- data/lib/uplink.rb +61 -0
- data/lib/uplink_lib.rb +345 -0
- metadata +82 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Uplink
|
4
|
+
class UplinkUtil
|
5
|
+
class << self
|
6
|
+
def get_system_values(object)
|
7
|
+
return if object.null? || object[:system].null?
|
8
|
+
|
9
|
+
[object[:system][:created], object[:system][:expires], object[:system][:content_length]]
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_custom_metadata(object)
|
13
|
+
custom = {}
|
14
|
+
|
15
|
+
return custom if object.null? || object[:custom].null?
|
16
|
+
|
17
|
+
count = object[:custom][:count]
|
18
|
+
mem_entries = object[:custom][:entries]
|
19
|
+
|
20
|
+
return custom if mem_entries.null?
|
21
|
+
|
22
|
+
count.times do |i|
|
23
|
+
entry = UplinkLib::UplinkCustomMetadataEntry.new(mem_entries + (i * UplinkLib::UplinkCustomMetadataEntry.size))
|
24
|
+
next if entry.null?
|
25
|
+
|
26
|
+
key = entry[:key].read_string
|
27
|
+
value = entry[:value].read_string
|
28
|
+
custom[key] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
custom
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_uplink_config(config)
|
35
|
+
raise ArgumentError, 'config argument is nil' if config.nil?
|
36
|
+
|
37
|
+
config_options = UplinkLib::UplinkConfig.new
|
38
|
+
user_agent = FFI::MemoryPointer.from_string(config[:user_agent]) if config[:user_agent]
|
39
|
+
temp_directory = FFI::MemoryPointer.from_string(config[:temp_directory]) if config[:temp_directory]
|
40
|
+
config_options[:user_agent] = user_agent
|
41
|
+
config_options[:dial_timeout_milliseconds] = config[:dial_timeout_milliseconds]&.to_i || 0
|
42
|
+
config_options[:temp_directory] = temp_directory
|
43
|
+
|
44
|
+
config_options
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_upload_options(options)
|
48
|
+
upload_options = nil
|
49
|
+
if options && !options.empty?
|
50
|
+
upload_options = UplinkLib::UplinkUploadOptions.new
|
51
|
+
upload_options[:expires] = options[:expires].to_i if options[:expires]
|
52
|
+
end
|
53
|
+
|
54
|
+
upload_options
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_custom_metadata(custom)
|
58
|
+
count = custom.size
|
59
|
+
mem_entries = FFI::MemoryPointer.new(UplinkLib::UplinkCustomMetadataEntry, count)
|
60
|
+
|
61
|
+
custom.to_a.each_with_index do |(key, value), i|
|
62
|
+
mem_key = FFI::MemoryPointer.from_string(key.to_s) if key
|
63
|
+
mem_value = FFI::MemoryPointer.from_string(value.to_s) if value
|
64
|
+
|
65
|
+
entry = UplinkLib::UplinkCustomMetadataEntry.new(mem_entries + (i * UplinkLib::UplinkCustomMetadataEntry.size))
|
66
|
+
entry[:key] = mem_key
|
67
|
+
entry[:key_length] = key ? key.length : 0
|
68
|
+
entry[:value] = mem_value
|
69
|
+
entry[:value_length] = value ? value.to_s.length : 0
|
70
|
+
end
|
71
|
+
|
72
|
+
custom_metadata = UplinkLib::UplinkCustomMetadata.new
|
73
|
+
custom_metadata[:count] = count
|
74
|
+
custom_metadata[:entries] = mem_entries
|
75
|
+
|
76
|
+
custom_metadata
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Uplink
|
4
|
+
class Upload
|
5
|
+
def initialize(upload_result)
|
6
|
+
@upload = upload_result[:upload]
|
7
|
+
end
|
8
|
+
|
9
|
+
def write(bytes, length)
|
10
|
+
raise ArgumentError, 'bytes argument is nil' if bytes.nil?
|
11
|
+
|
12
|
+
if bytes.is_a?(Array) && bytes.first.is_a?(Integer)
|
13
|
+
mem_bytes = FFI::MemoryPointer.new(:uint8, length)
|
14
|
+
mem_bytes.write_array_of_uint8(bytes)
|
15
|
+
else
|
16
|
+
mem_bytes = bytes
|
17
|
+
end
|
18
|
+
|
19
|
+
result = UplinkLib.uplink_upload_write(@upload, mem_bytes, length)
|
20
|
+
abort unless result[:error].null?
|
21
|
+
ErrorUtil.handle_result_error(result)
|
22
|
+
|
23
|
+
result[:bytes_written]
|
24
|
+
ensure
|
25
|
+
UplinkLib.uplink_free_write_result(result) if result
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_custom_metadata(custom)
|
29
|
+
custom_metadata = UplinkUtil.build_custom_metadata(custom)
|
30
|
+
|
31
|
+
error = UplinkLib.uplink_upload_set_custom_metadata(@upload, custom_metadata)
|
32
|
+
ErrorUtil.handle_error(error)
|
33
|
+
ensure
|
34
|
+
UplinkLib.uplink_free_error(error) if error
|
35
|
+
end
|
36
|
+
|
37
|
+
def commit
|
38
|
+
error = UplinkLib.uplink_upload_commit(@upload)
|
39
|
+
ErrorUtil.handle_error(error)
|
40
|
+
ensure
|
41
|
+
UplinkLib.uplink_free_error(error) if error
|
42
|
+
end
|
43
|
+
|
44
|
+
def abort
|
45
|
+
error = UplinkLib.uplink_upload_abort(@upload)
|
46
|
+
ErrorUtil.handle_error(error)
|
47
|
+
ensure
|
48
|
+
UplinkLib.uplink_free_error(error) if error
|
49
|
+
end
|
50
|
+
|
51
|
+
def info
|
52
|
+
result = UplinkLib.uplink_upload_info(@upload)
|
53
|
+
ErrorUtil.handle_result_error(result)
|
54
|
+
|
55
|
+
Object.new(result)
|
56
|
+
ensure
|
57
|
+
UplinkLib.uplink_free_object_result(result) if result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class UploadInfo
|
62
|
+
attr_reader :upload_id, :key, :is_prefix, :created, :expires, :content_length, :custom
|
63
|
+
|
64
|
+
def initialize(upload_info_result, upload_info = nil)
|
65
|
+
init_attributes(upload_info_result.nil? || upload_info_result.null? ? upload_info : upload_info_result[:info])
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def init_attributes(upload_info)
|
71
|
+
return if upload_info.nil? || upload_info.null?
|
72
|
+
|
73
|
+
@upload_id = upload_info[:upload_id]
|
74
|
+
@key = upload_info[:key]
|
75
|
+
@is_prefix = upload_info[:is_prefix]
|
76
|
+
@created, @expires, @content_length = UplinkUtil.get_system_values(upload_info)
|
77
|
+
@custom = UplinkUtil.get_custom_metadata(upload_info)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class PartUpload
|
82
|
+
def initialize(part_upload_result)
|
83
|
+
@part_upload = part_upload_result[:part_upload]
|
84
|
+
end
|
85
|
+
|
86
|
+
def write(bytes, length)
|
87
|
+
raise ArgumentError, 'bytes argument is nil' if bytes.nil?
|
88
|
+
|
89
|
+
if bytes.is_a?(Array) && bytes.first.is_a?(Integer)
|
90
|
+
mem_bytes = FFI::MemoryPointer.new(:uint8, length)
|
91
|
+
mem_bytes.write_array_of_uint8(bytes)
|
92
|
+
else
|
93
|
+
mem_bytes = bytes
|
94
|
+
end
|
95
|
+
|
96
|
+
result = UplinkLib.uplink_part_upload_write(@part_upload, mem_bytes, length)
|
97
|
+
abort unless result[:error].null?
|
98
|
+
ErrorUtil.handle_result_error(result)
|
99
|
+
|
100
|
+
result[:bytes_written]
|
101
|
+
ensure
|
102
|
+
UplinkLib.uplink_free_write_result(result) if result
|
103
|
+
end
|
104
|
+
|
105
|
+
def set_etag(etag)
|
106
|
+
error = UplinkLib.uplink_part_upload_set_etag(@part_upload, etag)
|
107
|
+
ErrorUtil.handle_error(error)
|
108
|
+
ensure
|
109
|
+
UplinkLib.uplink_free_error(error) if error
|
110
|
+
end
|
111
|
+
|
112
|
+
def commit
|
113
|
+
error = UplinkLib.uplink_part_upload_commit(@part_upload)
|
114
|
+
ErrorUtil.handle_error(error)
|
115
|
+
ensure
|
116
|
+
UplinkLib.uplink_free_error(error) if error
|
117
|
+
end
|
118
|
+
|
119
|
+
def abort
|
120
|
+
error = UplinkLib.uplink_part_upload_abort(@part_upload)
|
121
|
+
ErrorUtil.handle_error(error)
|
122
|
+
ensure
|
123
|
+
UplinkLib.uplink_free_error(error) if error
|
124
|
+
end
|
125
|
+
|
126
|
+
def info
|
127
|
+
result = UplinkLib.uplink_part_upload_info(@part_upload)
|
128
|
+
ErrorUtil.handle_result_error(result)
|
129
|
+
|
130
|
+
UploadPart.new(result)
|
131
|
+
ensure
|
132
|
+
UplinkLib.uplink_free_part_result(result) if result
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class UploadPart
|
137
|
+
attr_reader :part_number, :size, :modified, :etag
|
138
|
+
|
139
|
+
def initialize(upload_part_result, upload_part = nil)
|
140
|
+
init_attributes(upload_part_result.nil? || upload_part_result.null? ? upload_part : upload_part_result[:part])
|
141
|
+
end
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
def init_attributes(part)
|
146
|
+
return if part.nil? || part.null?
|
147
|
+
|
148
|
+
@part_number = part[:part_number]
|
149
|
+
@size = part[:size]
|
150
|
+
@modified = part[:modified]
|
151
|
+
@etag = part[:etag]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
class UploadIterator
|
156
|
+
def initialize(upload_iterator)
|
157
|
+
@upload_iterator = upload_iterator
|
158
|
+
end
|
159
|
+
|
160
|
+
def next?
|
161
|
+
has_next = UplinkLib.uplink_upload_iterator_next(@upload_iterator)
|
162
|
+
unless has_next
|
163
|
+
begin
|
164
|
+
error = UplinkLib.uplink_upload_iterator_err(@upload_iterator)
|
165
|
+
ErrorUtil.handle_error(error)
|
166
|
+
ensure
|
167
|
+
UplinkLib.uplink_free_error(error) if error
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
has_next
|
172
|
+
end
|
173
|
+
|
174
|
+
def item
|
175
|
+
upload_info = UplinkLib.uplink_upload_iterator_item(@upload_iterator)
|
176
|
+
UploadInfo.new(nil, upload_info)
|
177
|
+
ensure
|
178
|
+
UplinkLib.uplink_free_upload_info(upload_info) if upload_info
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class UploadPartIterator
|
183
|
+
def initialize(upload_part_iterator)
|
184
|
+
@upload_part_iterator = upload_part_iterator
|
185
|
+
end
|
186
|
+
|
187
|
+
def next?
|
188
|
+
has_next = UplinkLib.uplink_part_iterator_next(@upload_part_iterator)
|
189
|
+
unless has_next
|
190
|
+
begin
|
191
|
+
error = UplinkLib.uplink_part_iterator_err(@upload_part_iterator)
|
192
|
+
ErrorUtil.handle_error(error)
|
193
|
+
ensure
|
194
|
+
UplinkLib.uplink_free_error(error) if error
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
has_next
|
199
|
+
end
|
200
|
+
|
201
|
+
def item
|
202
|
+
upload_part = UplinkLib.uplink_part_iterator_item(@upload_part_iterator)
|
203
|
+
UploadPart.new(nil, upload_part)
|
204
|
+
ensure
|
205
|
+
UplinkLib.uplink_free_part(upload_part) if upload_part
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
data/lib/uplink.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uplink_lib'
|
4
|
+
require 'uplink/access'
|
5
|
+
require 'uplink/bucket'
|
6
|
+
require 'uplink/download'
|
7
|
+
require 'uplink/edge_credential'
|
8
|
+
require 'uplink/error_util'
|
9
|
+
require 'uplink/object'
|
10
|
+
require 'uplink/project'
|
11
|
+
require 'uplink/storj_error'
|
12
|
+
require 'uplink/uplink_util'
|
13
|
+
require 'uplink/upload'
|
14
|
+
|
15
|
+
module Uplink
|
16
|
+
class << self
|
17
|
+
def parse_access(access_string)
|
18
|
+
result = UplinkLib.uplink_parse_access(access_string)
|
19
|
+
ErrorUtil.handle_result_error(result)
|
20
|
+
|
21
|
+
yield Access.new(result)
|
22
|
+
ensure
|
23
|
+
UplinkLib.uplink_free_access_result(result) if result
|
24
|
+
end
|
25
|
+
|
26
|
+
def request_access_with_passphrase(satellite_address, api_key, passphrase)
|
27
|
+
result = UplinkLib.uplink_request_access_with_passphrase(satellite_address, api_key, passphrase)
|
28
|
+
ErrorUtil.handle_result_error(result)
|
29
|
+
|
30
|
+
yield Access.new(result)
|
31
|
+
ensure
|
32
|
+
UplinkLib.uplink_free_access_result(result) if result
|
33
|
+
end
|
34
|
+
|
35
|
+
def request_access_with_passphrase_and_config(config, satellite_address, api_key, passphrase)
|
36
|
+
config_options = UplinkUtil.build_uplink_config(config)
|
37
|
+
|
38
|
+
result = UplinkLib.uplink_config_request_access_with_passphrase(config_options, satellite_address, api_key, passphrase)
|
39
|
+
ErrorUtil.handle_result_error(result)
|
40
|
+
|
41
|
+
yield Access.new(result)
|
42
|
+
ensure
|
43
|
+
UplinkLib.uplink_free_access_result(result) if result
|
44
|
+
end
|
45
|
+
|
46
|
+
def derive_encryption_key(passphrase, salt, length)
|
47
|
+
raise ArgumentError, 'salt argument is not a string' unless salt.is_a?(String)
|
48
|
+
|
49
|
+
result = UplinkLib.uplink_derive_encryption_key(passphrase, salt, length)
|
50
|
+
ErrorUtil.handle_result_error(result)
|
51
|
+
|
52
|
+
yield result[:encryption_key]
|
53
|
+
ensure
|
54
|
+
UplinkLib.uplink_free_encryption_key_result(result) if result
|
55
|
+
end
|
56
|
+
|
57
|
+
def internal_universe_is_empty?
|
58
|
+
UplinkLib.uplink_internal_UniverseIsEmpty != 0
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/uplink_lib.rb
ADDED
@@ -0,0 +1,345 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
module UplinkLib
|
6
|
+
extend FFI::Library
|
7
|
+
|
8
|
+
ffi_lib 'libuplink.so'
|
9
|
+
|
10
|
+
class UplinkHandle < FFI::Struct
|
11
|
+
layout :_handle, :size_t
|
12
|
+
end
|
13
|
+
|
14
|
+
class UplinkAccess < FFI::Struct
|
15
|
+
layout :_handle, :size_t
|
16
|
+
end
|
17
|
+
|
18
|
+
class UplinkProject < FFI::Struct
|
19
|
+
layout :_handle, :size_t
|
20
|
+
end
|
21
|
+
|
22
|
+
class UplinkDownload < FFI::Struct
|
23
|
+
layout :_handle, :size_t
|
24
|
+
end
|
25
|
+
|
26
|
+
class UplinkUpload < FFI::Struct
|
27
|
+
layout :_handle, :size_t
|
28
|
+
end
|
29
|
+
|
30
|
+
class UplinkEncryptionKey < FFI::Struct
|
31
|
+
layout :_handle, :size_t
|
32
|
+
end
|
33
|
+
|
34
|
+
class UplinkPartUpload < FFI::Struct
|
35
|
+
layout :_handle, :size_t
|
36
|
+
end
|
37
|
+
|
38
|
+
class UplinkConfig < FFI::Struct
|
39
|
+
layout :user_agent, :pointer, # string
|
40
|
+
:dial_timeout_milliseconds, :int32_t,
|
41
|
+
:temp_directory, :pointer # string
|
42
|
+
end
|
43
|
+
|
44
|
+
class UplinkBucket < FFI::Struct
|
45
|
+
layout :name, :string,
|
46
|
+
:created, :int64_t
|
47
|
+
end
|
48
|
+
|
49
|
+
class UplinkSystemMetadata < FFI::Struct
|
50
|
+
layout :created, :int64_t,
|
51
|
+
:expires, :int64_t,
|
52
|
+
:content_length, :int64_t
|
53
|
+
end
|
54
|
+
|
55
|
+
class UplinkCustomMetadataEntry < FFI::Struct
|
56
|
+
layout :key, :pointer, # string
|
57
|
+
:key_length, :size_t,
|
58
|
+
:value, :pointer, # string
|
59
|
+
:value_length, :size_t
|
60
|
+
end
|
61
|
+
|
62
|
+
class UplinkCustomMetadata < FFI::Struct
|
63
|
+
layout :entries, :pointer, # array of UplinkCustomMetadataEntry
|
64
|
+
:count, :size_t
|
65
|
+
end
|
66
|
+
|
67
|
+
class UplinkObject < FFI::Struct
|
68
|
+
layout :key, :string,
|
69
|
+
:is_prefix, :bool,
|
70
|
+
:system, UplinkSystemMetadata.val,
|
71
|
+
:custom, UplinkCustomMetadata.val
|
72
|
+
end
|
73
|
+
|
74
|
+
class UplinkUploadOptions < FFI::Struct
|
75
|
+
layout :expires, :int64_t
|
76
|
+
end
|
77
|
+
|
78
|
+
class UplinkDownloadOptions < FFI::Struct
|
79
|
+
layout :offset, :int64_t,
|
80
|
+
:length, :int64_t
|
81
|
+
end
|
82
|
+
|
83
|
+
class UplinkListObjectsOptions < FFI::Struct
|
84
|
+
layout :prefix, :pointer, # string
|
85
|
+
:cursor, :pointer, # string
|
86
|
+
:recursive, :bool,
|
87
|
+
:system, :bool,
|
88
|
+
:custom, :bool
|
89
|
+
end
|
90
|
+
|
91
|
+
class UplinkListUploadsOptions < FFI::Struct
|
92
|
+
layout :prefix, :pointer, # string
|
93
|
+
:cursor, :pointer, # string
|
94
|
+
:recursive, :bool,
|
95
|
+
:system, :bool,
|
96
|
+
:custom, :bool
|
97
|
+
end
|
98
|
+
|
99
|
+
class UplinkListBucketsOptions < FFI::Struct
|
100
|
+
layout :cursor, :pointer # string
|
101
|
+
end
|
102
|
+
|
103
|
+
class UplinkObjectIterator < FFI::Struct
|
104
|
+
layout :_handle, :size_t
|
105
|
+
end
|
106
|
+
|
107
|
+
class UplinkBucketIterator < FFI::Struct
|
108
|
+
layout :_handle, :size_t
|
109
|
+
end
|
110
|
+
|
111
|
+
class UplinkUploadIterator < FFI::Struct
|
112
|
+
layout :_handle, :size_t
|
113
|
+
end
|
114
|
+
|
115
|
+
class UplinkPartIterator < FFI::Struct
|
116
|
+
layout :_handle, :size_t
|
117
|
+
end
|
118
|
+
|
119
|
+
class UplinkPermission < FFI::Struct
|
120
|
+
layout :allow_download, :bool,
|
121
|
+
:allow_upload, :bool,
|
122
|
+
:allow_list, :bool,
|
123
|
+
:allow_delete, :bool,
|
124
|
+
:not_before, :int64_t,
|
125
|
+
:not_after, :int64_t
|
126
|
+
end
|
127
|
+
|
128
|
+
class UplinkPart < FFI::Struct
|
129
|
+
layout :part_number, :uint32_t,
|
130
|
+
:size, :size_t,
|
131
|
+
:modified, :int64_t,
|
132
|
+
:etag, :string,
|
133
|
+
:etag_length, :size_t
|
134
|
+
end
|
135
|
+
|
136
|
+
class UplinkSharePrefix < FFI::Struct
|
137
|
+
layout :bucket, :pointer, # string
|
138
|
+
:prefix, :pointer # string
|
139
|
+
end
|
140
|
+
|
141
|
+
class UplinkError < FFI::Struct
|
142
|
+
layout :code, :int32_t,
|
143
|
+
:message, :string
|
144
|
+
end
|
145
|
+
|
146
|
+
class UplinkAccessResult < FFI::Struct
|
147
|
+
layout :access, UplinkAccess.ptr,
|
148
|
+
:error, UplinkError.ptr
|
149
|
+
end
|
150
|
+
|
151
|
+
class UplinkProjectResult < FFI::Struct
|
152
|
+
layout :project, UplinkProject.ptr,
|
153
|
+
:error, UplinkError.ptr
|
154
|
+
end
|
155
|
+
|
156
|
+
class UplinkBucketResult < FFI::Struct
|
157
|
+
layout :bucket, UplinkBucket.ptr,
|
158
|
+
:error, UplinkError.ptr
|
159
|
+
end
|
160
|
+
|
161
|
+
class UplinkObjectResult < FFI::Struct
|
162
|
+
layout :object, UplinkObject.ptr,
|
163
|
+
:error, UplinkError.ptr
|
164
|
+
end
|
165
|
+
|
166
|
+
class UplinkUploadResult < FFI::Struct
|
167
|
+
layout :upload, UplinkUpload.ptr,
|
168
|
+
:error, UplinkError.ptr
|
169
|
+
end
|
170
|
+
|
171
|
+
class UplinkPartUploadResult < FFI::Struct
|
172
|
+
layout :part_upload, UplinkPartUpload.ptr,
|
173
|
+
:error, UplinkError.ptr
|
174
|
+
end
|
175
|
+
|
176
|
+
class UplinkDownloadResult < FFI::Struct
|
177
|
+
layout :download, UplinkDownload.ptr,
|
178
|
+
:error, UplinkError.ptr
|
179
|
+
end
|
180
|
+
|
181
|
+
class UplinkWriteResult < FFI::Struct
|
182
|
+
layout :bytes_written, :size_t,
|
183
|
+
:error, UplinkError.ptr
|
184
|
+
end
|
185
|
+
|
186
|
+
class UplinkReadResult < FFI::Struct
|
187
|
+
layout :bytes_read, :size_t,
|
188
|
+
:error, UplinkError.ptr
|
189
|
+
end
|
190
|
+
|
191
|
+
class UplinkStringResult < FFI::Struct
|
192
|
+
layout :string, :string,
|
193
|
+
:error, UplinkError.ptr
|
194
|
+
end
|
195
|
+
|
196
|
+
class UplinkEncryptionKeyResult < FFI::Struct
|
197
|
+
layout :encryption_key, UplinkEncryptionKey.ptr,
|
198
|
+
:error, UplinkError.ptr
|
199
|
+
end
|
200
|
+
|
201
|
+
class UplinkUploadInfo < FFI::Struct
|
202
|
+
layout :upload_id, :string,
|
203
|
+
:key, :string,
|
204
|
+
:is_prefix, :bool,
|
205
|
+
:system, UplinkSystemMetadata.val,
|
206
|
+
:custom, UplinkCustomMetadata.val
|
207
|
+
end
|
208
|
+
|
209
|
+
class UplinkUploadInfoResult < FFI::Struct
|
210
|
+
layout :info, UplinkUploadInfo.ptr,
|
211
|
+
:error, UplinkError.ptr
|
212
|
+
end
|
213
|
+
|
214
|
+
class UplinkCommitUploadOptions < FFI::Struct
|
215
|
+
layout :custom_metadata, UplinkCustomMetadata.val
|
216
|
+
end
|
217
|
+
|
218
|
+
class UplinkCommitUploadResult < FFI::Struct
|
219
|
+
layout :object, UplinkObject.ptr,
|
220
|
+
:error, UplinkError.ptr
|
221
|
+
end
|
222
|
+
|
223
|
+
class UplinkPartResult < FFI::Struct
|
224
|
+
layout :part, UplinkPart.ptr,
|
225
|
+
:error, UplinkError.ptr
|
226
|
+
end
|
227
|
+
|
228
|
+
class UplinkListUploadPartsOptions < FFI::Struct
|
229
|
+
layout :cursor, :uint32_t
|
230
|
+
end
|
231
|
+
|
232
|
+
class EdgeConfig < FFI::Struct
|
233
|
+
layout :auth_service_address, :pointer, # string
|
234
|
+
:certificate_pem, :pointer # string
|
235
|
+
end
|
236
|
+
|
237
|
+
class EdgeRegisterAccessOptions < FFI::Struct
|
238
|
+
layout :is_public, :bool
|
239
|
+
end
|
240
|
+
|
241
|
+
class EdgeCredentials < FFI::Struct
|
242
|
+
layout :access_key_id, :string,
|
243
|
+
:secret_key, :string,
|
244
|
+
:endpoint, :string
|
245
|
+
end
|
246
|
+
|
247
|
+
class EdgeCredentialsResult < FFI::Struct
|
248
|
+
layout :credentials, EdgeCredentials.ptr,
|
249
|
+
:error, UplinkError.ptr
|
250
|
+
end
|
251
|
+
|
252
|
+
class EdgeShareURLOptions < FFI::Struct
|
253
|
+
layout :raw, :bool
|
254
|
+
end
|
255
|
+
|
256
|
+
class UplinkMoveObjectOptions < FFI::Struct; end
|
257
|
+
class UplinkUploadObjectMetadataOptions < FFI::Struct; end
|
258
|
+
class UplinkCopyObjectOptions < FFI::Struct; end
|
259
|
+
|
260
|
+
attach_function :uplink_parse_access, [:string], UplinkAccessResult.val
|
261
|
+
attach_function :uplink_request_access_with_passphrase, [:string, :string, :string], UplinkAccessResult.val
|
262
|
+
attach_function :uplink_access_satellite_address, [UplinkAccess.ptr], UplinkStringResult.val
|
263
|
+
attach_function :uplink_access_serialize, [UplinkAccess.ptr], UplinkStringResult.val
|
264
|
+
attach_function :uplink_access_share, [UplinkAccess.ptr, UplinkPermission.val, :pointer, :long_long], UplinkAccessResult.val
|
265
|
+
attach_function :uplink_access_override_encryption_key, [UplinkAccess.ptr, :string, :string, UplinkEncryptionKey.ptr], UplinkError.ptr
|
266
|
+
attach_function :uplink_free_string_result, [UplinkStringResult.val], :void
|
267
|
+
attach_function :uplink_free_access_result, [UplinkAccessResult.val], :void
|
268
|
+
attach_function :uplink_stat_bucket, [UplinkProject.ptr, :string], UplinkBucketResult.val
|
269
|
+
attach_function :uplink_create_bucket, [UplinkProject.ptr, :string], UplinkBucketResult.val
|
270
|
+
attach_function :uplink_ensure_bucket, [UplinkProject.ptr, :string], UplinkBucketResult.val
|
271
|
+
attach_function :uplink_delete_bucket, [UplinkProject.ptr, :string], UplinkBucketResult.val
|
272
|
+
attach_function :uplink_delete_bucket_with_objects, [UplinkProject.ptr, :string], UplinkBucketResult.val
|
273
|
+
attach_function :uplink_free_bucket_result, [UplinkBucketResult.val], :void
|
274
|
+
attach_function :uplink_free_bucket, [UplinkBucket.ptr], :void
|
275
|
+
attach_function :uplink_list_buckets, [UplinkProject.ptr, UplinkListBucketsOptions.ptr], UplinkBucketIterator.ptr
|
276
|
+
attach_function :uplink_bucket_iterator_next, [UplinkBucketIterator.ptr], :bool
|
277
|
+
attach_function :uplink_bucket_iterator_err, [UplinkBucketIterator.ptr], UplinkError.ptr
|
278
|
+
attach_function :uplink_bucket_iterator_item, [UplinkBucketIterator.ptr], UplinkBucket.ptr
|
279
|
+
attach_function :uplink_free_bucket_iterator, [UplinkBucketIterator.ptr], :void
|
280
|
+
attach_function :uplink_config_request_access_with_passphrase, [UplinkConfig.val, :string, :string, :string], UplinkAccessResult.val
|
281
|
+
attach_function :uplink_config_open_project, [UplinkConfig.val, UplinkAccess.ptr], UplinkProjectResult.val
|
282
|
+
attach_function :uplink_copy_object, [UplinkProject.ptr, :string, :string, :string, :string, UplinkCopyObjectOptions.ptr], UplinkObjectResult.val
|
283
|
+
attach_function :uplink_download_object, [UplinkProject.ptr, :string, :string, UplinkDownloadOptions.ptr], UplinkDownloadResult.val
|
284
|
+
attach_function :uplink_download_read, [UplinkDownload.ptr, :pointer, :size_t], UplinkReadResult.val
|
285
|
+
attach_function :uplink_download_info, [UplinkDownload.ptr], UplinkObjectResult.val
|
286
|
+
attach_function :uplink_free_read_result, [UplinkReadResult.val], :void
|
287
|
+
attach_function :uplink_close_download, [UplinkDownload.ptr], UplinkError.ptr
|
288
|
+
attach_function :uplink_free_download_result, [UplinkDownloadResult.val], :void
|
289
|
+
attach_function :edge_register_access, [EdgeConfig.val, UplinkAccess.ptr, EdgeRegisterAccessOptions.ptr], EdgeCredentialsResult.val
|
290
|
+
attach_function :edge_free_credentials_result, [EdgeCredentialsResult.val], :void
|
291
|
+
attach_function :edge_free_credentials, [EdgeCredentials.ptr], :void
|
292
|
+
attach_function :edge_join_share_url, [:string, :string, :string, :string, EdgeShareURLOptions.ptr], UplinkStringResult.val
|
293
|
+
attach_function :uplink_derive_encryption_key, [:string, :pointer, :size_t], UplinkEncryptionKeyResult.val
|
294
|
+
attach_function :uplink_free_encryption_key_result, [UplinkEncryptionKeyResult.val], :void
|
295
|
+
attach_function :uplink_free_error, [UplinkError.ptr], :void
|
296
|
+
attach_function :uplink_internal_UniverseIsEmpty, [], :uchar
|
297
|
+
attach_function :uplink_move_object, [UplinkProject.ptr, :string, :string, :string, :string, UplinkMoveObjectOptions.ptr], UplinkError.ptr
|
298
|
+
attach_function :uplink_begin_upload, [UplinkProject.ptr, :string, :string, UplinkUploadOptions.ptr], UplinkUploadInfoResult.val
|
299
|
+
attach_function :uplink_free_upload_info_result, [UplinkUploadInfoResult.val], :void
|
300
|
+
attach_function :uplink_free_upload_info, [UplinkUploadInfo.ptr], :void
|
301
|
+
attach_function :uplink_commit_upload, [UplinkProject.ptr, :string, :string, :string, UplinkCommitUploadOptions.ptr], UplinkCommitUploadResult.val
|
302
|
+
attach_function :uplink_free_commit_upload_result, [UplinkCommitUploadResult.val], :void
|
303
|
+
attach_function :uplink_abort_upload, [UplinkProject.ptr, :string, :string, :string], UplinkError.ptr
|
304
|
+
attach_function :uplink_upload_part, [UplinkProject.ptr, :string, :string, :string, :uint32_t], UplinkPartUploadResult.val
|
305
|
+
attach_function :uplink_part_upload_write, [UplinkPartUpload.ptr, :pointer, :size_t], UplinkWriteResult.val
|
306
|
+
attach_function :uplink_part_upload_commit, [UplinkPartUpload.ptr], UplinkError.ptr
|
307
|
+
attach_function :uplink_part_upload_abort, [UplinkPartUpload.ptr], UplinkError.ptr
|
308
|
+
attach_function :uplink_part_upload_set_etag, [UplinkPartUpload.ptr, :string], UplinkError.ptr
|
309
|
+
attach_function :uplink_part_upload_info, [UplinkPartUpload.ptr], UplinkPartResult.val
|
310
|
+
attach_function :uplink_free_part_result, [UplinkPartResult.val], :void
|
311
|
+
attach_function :uplink_free_part_upload_result, [UplinkPartUploadResult.val], :void
|
312
|
+
attach_function :uplink_free_part, [UplinkPart.ptr], :void
|
313
|
+
attach_function :uplink_list_uploads, [UplinkProject.ptr, :string, UplinkListUploadsOptions.ptr], UplinkUploadIterator.ptr
|
314
|
+
attach_function :uplink_upload_iterator_next, [UplinkUploadIterator.ptr], :bool
|
315
|
+
attach_function :uplink_upload_iterator_err, [UplinkUploadIterator.ptr], UplinkError.ptr
|
316
|
+
attach_function :uplink_upload_iterator_item, [UplinkUploadIterator.ptr], UplinkUploadInfo.ptr
|
317
|
+
attach_function :uplink_free_upload_iterator, [UplinkUploadIterator.ptr], :void
|
318
|
+
attach_function :uplink_list_upload_parts, [UplinkProject.ptr, :string, :string, :string, UplinkListUploadPartsOptions.ptr], UplinkPartIterator.ptr
|
319
|
+
attach_function :uplink_part_iterator_next, [UplinkPartIterator.ptr], :bool
|
320
|
+
attach_function :uplink_part_iterator_err, [UplinkPartIterator.ptr], UplinkError.ptr
|
321
|
+
attach_function :uplink_part_iterator_item, [UplinkPartIterator.ptr], UplinkPart.ptr
|
322
|
+
attach_function :uplink_free_part_iterator, [UplinkPartIterator.ptr], :void
|
323
|
+
attach_function :uplink_stat_object, [UplinkProject.ptr, :string, :string], UplinkObjectResult.val
|
324
|
+
attach_function :uplink_delete_object, [UplinkProject.ptr, :string, :string], UplinkObjectResult.val
|
325
|
+
attach_function :uplink_free_object_result, [UplinkObjectResult.val], :void
|
326
|
+
attach_function :uplink_free_object, [UplinkObject.ptr], :void
|
327
|
+
attach_function :uplink_update_object_metadata, [UplinkProject.ptr, :string, :string, UplinkCustomMetadata.val, UplinkUploadObjectMetadataOptions.ptr], UplinkError.ptr
|
328
|
+
attach_function :uplink_list_objects, [UplinkProject.ptr, :string, UplinkListObjectsOptions.ptr], UplinkObjectIterator.ptr
|
329
|
+
attach_function :uplink_object_iterator_next, [UplinkObjectIterator.ptr], :bool
|
330
|
+
attach_function :uplink_object_iterator_err, [UplinkObjectIterator.ptr], UplinkError.ptr
|
331
|
+
attach_function :uplink_object_iterator_item, [UplinkObjectIterator.ptr], UplinkObject.ptr
|
332
|
+
attach_function :uplink_free_object_iterator, [UplinkObjectIterator.ptr], :void
|
333
|
+
attach_function :uplink_open_project, [UplinkAccess.ptr], UplinkProjectResult.val
|
334
|
+
attach_function :uplink_close_project, [UplinkProject.ptr], UplinkError.ptr
|
335
|
+
attach_function :uplink_free_project_result, [UplinkProjectResult.val], :void
|
336
|
+
attach_function :uplink_revoke_access, [UplinkProject.ptr, UplinkAccess.ptr], UplinkError.ptr
|
337
|
+
attach_function :uplink_upload_object, [UplinkProject.ptr, :string, :string, UplinkUploadOptions.ptr], UplinkUploadResult.val
|
338
|
+
attach_function :uplink_upload_write, [UplinkUpload.ptr, :pointer, :size_t], UplinkWriteResult.val
|
339
|
+
attach_function :uplink_upload_commit, [UplinkUpload.ptr], UplinkError.ptr
|
340
|
+
attach_function :uplink_upload_abort, [UplinkUpload.ptr], UplinkError.ptr
|
341
|
+
attach_function :uplink_upload_info, [UplinkUpload.ptr], UplinkObjectResult.val
|
342
|
+
attach_function :uplink_upload_set_custom_metadata, [UplinkUpload.ptr, UplinkCustomMetadata.val], UplinkError.ptr
|
343
|
+
attach_function :uplink_free_write_result, [UplinkWriteResult.val], :void
|
344
|
+
attach_function :uplink_free_upload_result, [UplinkUploadResult.val], :void
|
345
|
+
end
|