Module: Uplink

Defined in:
lib/uplink.rb,
lib/uplink/access.rb,
lib/uplink/bucket.rb,
lib/uplink/object.rb,
lib/uplink/upload.rb,
lib/uplink/project.rb,
lib/uplink/download.rb,
lib/uplink/error_util.rb,
lib/uplink/storj_error.rb,
lib/uplink/uplink_util.rb,
lib/uplink/edge_credential.rb

Defined Under Namespace

Classes: Access, BandwidthLimitExceededError, Bucket, BucketAlreadyExistsError, BucketIterator, BucketNameInvalidError, BucketNotEmptyError, BucketNotFoundError, CanceledError, Download, EdgeAuthDialFailedError, EdgeCredential, EdgeRegisterAccessFailedError, ErrorUtil, InternalError, InvalidHandleError, Object, ObjectIterator, ObjectKeyInvalidError, ObjectKeyNotFoundError, PartUpload, Project, SegmentsLimitExceededError, StorageLimitExceededError, StorjError, TooManyRequestError, UplinkUtil, Upload, UploadDoneError, UploadInfo, UploadIterator, UploadPart, UploadPartIterator

Constant Summary collapse

EOF =
-1
0x02
0x03
0x04
0x05
0x06
0x07
0x08
0x10
0x11
0x12
0x13
0x20
0x21
0x22
EDGE_ERROR_AUTH_DIAL_FAILED =
0x30
EDGE_ERROR_REGISTER_ACCESS_FAILED =
0x31
CODE_TO_ERROR_MAPPING =
{
  UPLINK_ERROR_INTERNAL => InternalError,
  UPLINK_ERROR_CANCELED => CanceledError,
  UPLINK_ERROR_INVALID_HANDLE => InvalidHandleError,
  UPLINK_ERROR_TOO_MANY_REQUESTS => TooManyRequestError,
  UPLINK_ERROR_BANDWIDTH_LIMIT_EXCEEDED => BandwidthLimitExceededError,
  UPLINK_ERROR_STORAGE_LIMIT_EXCEEDED => StorageLimitExceededError,
  UPLINK_ERROR_SEGMENTS_LIMIT_EXCEEDED => SegmentsLimitExceededError,
  UPLINK_ERROR_BUCKET_NAME_INVALID => BucketNameInvalidError,
  UPLINK_ERROR_BUCKET_ALREADY_EXISTS => BucketAlreadyExistsError,
  UPLINK_ERROR_BUCKET_NOT_EMPTY => BucketNotEmptyError,
  UPLINK_ERROR_BUCKET_NOT_FOUND => BucketNotFoundError,
  UPLINK_ERROR_OBJECT_KEY_INVALID => ObjectKeyInvalidError,
  UPLINK_ERROR_OBJECT_NOT_FOUND => ObjectKeyNotFoundError,
  UPLINK_ERROR_UPLOAD_DONE => UploadDoneError,
  EDGE_ERROR_AUTH_DIAL_FAILED => EdgeAuthDialFailedError,
  EDGE_ERROR_REGISTER_ACCESS_FAILED => EdgeRegisterAccessFailedError
}.freeze

Class Method Summary collapse

Class Method Details

.derive_encryption_key(passphrase, salt, length) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/uplink.rb', line 46

def derive_encryption_key(passphrase, salt, length)
  raise ArgumentError, 'salt argument is not a string' unless salt.is_a?(String)

  result = UplinkLib.uplink_derive_encryption_key(passphrase, salt, length)
  ErrorUtil.handle_result_error(result)

  yield result[:encryption_key]
ensure
  UplinkLib.uplink_free_encryption_key_result(result) if result
end

.internal_universe_is_empty?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/uplink.rb', line 57

def internal_universe_is_empty?
  UplinkLib.uplink_internal_UniverseIsEmpty != 0
end

.parse_access(access_string) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/uplink.rb', line 17

def parse_access(access_string)
  result = UplinkLib.uplink_parse_access(access_string)
  ErrorUtil.handle_result_error(result)

  yield Access.new(result)
ensure
  UplinkLib.uplink_free_access_result(result) if result
end

.request_access_with_passphrase(satellite_address, api_key, passphrase) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/uplink.rb', line 26

def request_access_with_passphrase(satellite_address, api_key, passphrase)
  result = UplinkLib.uplink_request_access_with_passphrase(satellite_address, api_key, passphrase)
  ErrorUtil.handle_result_error(result)

  yield Access.new(result)
ensure
  UplinkLib.uplink_free_access_result(result) if result
end

.request_access_with_passphrase_and_config(config, satellite_address, api_key, passphrase) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/uplink.rb', line 35

def request_access_with_passphrase_and_config(config, satellite_address, api_key, passphrase)
  config_options = UplinkUtil.build_uplink_config(config)

  result = UplinkLib.uplink_config_request_access_with_passphrase(config_options, satellite_address, api_key, passphrase)
  ErrorUtil.handle_result_error(result)

  yield Access.new(result)
ensure
  UplinkLib.uplink_free_access_result(result) if result
end