mobile

package
v0.14.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2019 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mobile contains the simplified mobile APIs to Storj Network.

For API limitations see https://github.com/ethereum/go-ethereum/blob/461291882edce0ac4a28f64c4e8725b7f57cbeae/mobile/doc.go#L23

build loop for development

watchrun gobind -lang=java -outdir=../mobile-out storj.io/storj/mobile == pt skipped ../mobile-out

gomobile bind -target android

To use:

gomobile bind -target android

Create a new project in AndroidStudio

Copy mobile-source.jar and mobile.aar into `AndroidStudioProjects\MyApplication\app\libs\`

Modify build.gradle to also find *.aar files:

implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

See example Java file

Index

Constants

View Source
const (
	// CipherSuiteEncUnspecified indicates no encryption suite has been selected.
	CipherSuiteEncUnspecified = byte(storj.EncUnspecified)
	// CipherSuiteEncNull indicates use of the NULL cipher; that is, no encryption is
	// done. The ciphertext is equal to the plaintext.
	CipherSuiteEncNull = byte(storj.EncNull)
	// CipherSuiteEncAESGCM indicates use of AES128-GCM encryption.
	CipherSuiteEncAESGCM = byte(storj.EncAESGCM)
	// CipherSuiteEncSecretBox indicates use of XSalsa20-Poly1305 encryption, as provided
	// by the NaCl cryptography library under the name "Secretbox".
	CipherSuiteEncSecretBox = byte(storj.EncSecretBox)

	// DirectionAfter lists forwards from cursor, without cursor
	DirectionAfter = int(storj.After)
	// DirectionForward lists forwards from cursor, including cursor
	DirectionForward = int(storj.Forward)
	// DirectionBackward lists backwards from cursor, including cursor
	DirectionBackward = int(storj.Backward)
	// DirectionBefore lists backwards from cursor, without cursor
	DirectionBefore = int(storj.Before)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Name string
	// contains filtered or unexported fields
}

Bucket represents operations you can perform on a bucket

func (*Bucket) Close

func (bucket *Bucket) Close() error

Close closes the Bucket session.

func (*Bucket) DeleteObject

func (bucket *Bucket) DeleteObject(objectPath string) error

DeleteObject removes an object, if authorized.

func (*Bucket) ListObjects

func (bucket *Bucket) ListObjects(options *ListOptions) (*ObjectList, error)

ListObjects list objects in bucket, if authorized.

func (*Bucket) NewReader

func (bucket *Bucket) NewReader(path storj.Path, options *ReaderOptions) (*Reader, error)

NewReader returns new reader for downloading object

func (*Bucket) NewWriter

func (bucket *Bucket) NewWriter(path storj.Path, options *WriterOptions) (*Writer, error)

NewWriter creates instance of Writer

func (*Bucket) OpenObject

func (bucket *Bucket) OpenObject(objectPath string) (*ObjectInfo, error)

OpenObject returns an Object handle, if authorized.

type BucketConfig

type BucketConfig struct {
	// PathCipher indicates which cipher suite is to be used for path
	// encryption within the new Bucket. If not set, AES-GCM encryption
	// will be used.
	PathCipher byte

	// EncryptionParameters specifies the default encryption parameters to
	// be used for data encryption of new Objects in this bucket.
	EncryptionParameters *EncryptionParameters

	// RedundancyScheme defines the default Reed-Solomon and/or
	// Forward Error Correction encoding parameters to be used by
	// objects in this Bucket.
	RedundancyScheme *RedundancyScheme
	// SegmentsSize is the default segment size to use for new
	// objects in this Bucket.
	SegmentsSize int64
}

BucketConfig bucket configuration

type BucketInfo

type BucketInfo struct {
	Name                 string
	Created              int64
	PathCipher           byte
	SegmentsSize         int64
	RedundancyScheme     *RedundancyScheme
	EncryptionParameters *EncryptionParameters
}

BucketInfo bucket meta struct

type BucketList

type BucketList struct {
	// contains filtered or unexported fields
}

BucketList is a list of buckets

func (*BucketList) Item

func (bl *BucketList) Item(index int) (*BucketInfo, error)

Item gets item from specific index

func (*BucketList) Length

func (bl *BucketList) Length() int

Length returns number of returned items

func (*BucketList) More

func (bl *BucketList) More() bool

More returns true if list request was not able to return all results

type Config

type Config struct {

	// MaxInlineSize determines whether the uplink will attempt to
	// store a new object in the satellite's metainfo. Objects at
	// or below this size will be marked for inline storage, and
	// objects above this size will not. (The satellite may reject
	// the inline storage and require remote storage, still.)
	MaxInlineSize int64

	// MaxMemory is the default maximum amount of memory to be
	// allocated for read buffers while performing decodes of
	// objects. (This option is overrideable per Bucket if the user
	// so desires.) If set to zero, the library default (4 MiB) will
	// be used. If set to a negative value, the system will use the
	// smallest amount of memory it can.
	MaxMemory int64
}

Config represents configuration options for an Uplink

type EncryptionAccess added in v0.14.5

type EncryptionAccess struct {
	// contains filtered or unexported fields
}

EncryptionAccess holds data about encryption keys for a bucket.

func NewEncryptionAccess added in v0.14.5

func NewEncryptionAccess() *EncryptionAccess

NewEncryptionAccess constructs an empty encryption context.

func ParseEncryptionAccess added in v0.14.5

func ParseEncryptionAccess(b58data string) (*EncryptionAccess, error)

ParseEncryptionAccess parses the base58 encoded encryption context data and returns the resulting context.

func (*EncryptionAccess) SetDefaultKey added in v0.14.5

func (e *EncryptionAccess) SetDefaultKey(keyData []byte) error

SetDefaultKey sets the default key to use when no matching keys are found for the encryption context.

type EncryptionParameters

type EncryptionParameters struct {
	// CipherSuite specifies the cipher suite to be used for encryption.
	CipherSuite byte
	// BlockSize determines the unit size at which encryption is performed.
	// It is important to distinguish this from the block size used by the
	// cipher suite (probably 128 bits). There is some small overhead for
	// each encryption unit, so BlockSize should not be too small, but
	// smaller sizes yield shorter first-byte latency and better seek times.
	// Note that BlockSize itself is the size of data blocks _after_ they
	// have been encrypted and the authentication overhead has been added.
	// It is _not_ the size of the data blocks to _be_ encrypted.
	BlockSize int32
}

EncryptionParameters is the cipher suite and parameters used for encryption It is like EncryptionScheme, but uses the CipherSuite type instead of Cipher. EncryptionParameters is preferred for new uses.

type ListOptions

type ListOptions struct {
	Prefix    string
	Cursor    string // Cursor is relative to Prefix, full path is Prefix + Cursor
	Delimiter int32
	Recursive bool
	Direction int
	Limit     int
}

ListOptions options for listing objects

type ObjectInfo

type ObjectInfo struct {
	Version     int32
	Bucket      string
	Path        string
	IsPrefix    bool
	Size        int64
	ContentType string
	Created     int64
	Modified    int64
	Expires     int64
	// contains filtered or unexported fields
}

ObjectInfo object metadata

func (*ObjectInfo) GetMetadata

func (bl *ObjectInfo) GetMetadata(key string) string

GetMetadata gets objects custom metadata

type ObjectList

type ObjectList struct {
	// contains filtered or unexported fields
}

ObjectList represents list of objects

func (*ObjectList) Bucket

func (bl *ObjectList) Bucket() string

Bucket returns bucket name

func (*ObjectList) Item

func (bl *ObjectList) Item(index int) (*ObjectInfo, error)

Item gets item from specific index

func (*ObjectList) Length

func (bl *ObjectList) Length() int

Length returns number of returned items

func (*ObjectList) More

func (bl *ObjectList) More() bool

More returns true if list request was not able to return all results

func (*ObjectList) Prefix

func (bl *ObjectList) Prefix() string

Prefix prefix for objects from list

type Project

type Project struct {
	// contains filtered or unexported fields
}

Project represents a specific project access session.

func (*Project) Close

func (project *Project) Close() error

Close closes the Project

func (*Project) CreateBucket

func (project *Project) CreateBucket(bucketName string, opts *BucketConfig) (*BucketInfo, error)

CreateBucket creates buckets in project

func (*Project) DeleteBucket

func (project *Project) DeleteBucket(bucketName string) error

DeleteBucket deletes a bucket if authorized. If the bucket contains any Objects at the time of deletion, they may be lost permanently.

func (*Project) GetBucketInfo

func (project *Project) GetBucketInfo(bucketName string) (*BucketInfo, error)

GetBucketInfo returns info about the requested bucket if authorized.

func (*Project) ListBuckets

func (project *Project) ListBuckets(cursor string, direction, limit int) (*BucketList, error)

ListBuckets will list authorized buckets.

func (*Project) OpenBucket

func (project *Project) OpenBucket(bucketName string, access *EncryptionAccess) (*Bucket, error)

OpenBucket returns a Bucket handle with the given EncryptionAccess information.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reader for downloading object

func (*Reader) Cancel

func (r *Reader) Cancel()

Cancel cancels read operation

func (*Reader) Close

func (r *Reader) Close() error

Close closes reader

func (*Reader) Read

func (r *Reader) Read(data []byte) (n int32, err error)

Read reads data into byte array

type ReaderOptions

type ReaderOptions struct {
}

ReaderOptions options for reading

type RedundancyScheme

type RedundancyScheme struct {
	// Algorithm determines the algorithm to be used for redundancy.
	Algorithm byte

	// ShareSize is the size to use for new redundancy shares.
	ShareSize int32

	// RequiredShares is the minimum number of shares required to recover a
	// segment.
	RequiredShares int16
	// RepairShares is the minimum number of safe shares that can remain
	// before a repair is triggered.
	RepairShares int16
	// OptimalShares is the desired total number of shares for a segment.
	OptimalShares int16
	// TotalShares is the number of shares to encode. If it is larger than
	// OptimalShares, slower uploads of the excess shares will be aborted in
	// order to improve performance.
	TotalShares int16
}

RedundancyScheme specifies the parameters and the algorithm for redundancy

type Uplink struct {
	// contains filtered or unexported fields
}

Uplink represents the main entrypoint to Storj V3. An Uplink connects to a specific Satellite and caches connections and resources, allowing one to create sessions delineated by specific access controls.

func NewUplink(config *Config, tempDir string) (*Uplink, error)

NewUplink creates a new Uplink. This is the first step to create an uplink session with a user specified config or with default config, if nil config. Uplink needs also writable temporary directory.

func (*Uplink) Close

func (uplink *Uplink) Close() error

Close closes the Uplink. This may not do anything at present, but should still be called to allow forward compatibility. No Project or Bucket objects using this Uplink should be used after calling Close.

func (*Uplink) OpenProject

func (uplink *Uplink) OpenProject(satellite string, apikey string) (*Project, error)

OpenProject returns a Project handle with the given APIKey

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes data into object

func (*Writer) Cancel

func (w *Writer) Cancel()

Cancel cancels writing operation

func (*Writer) Close

func (w *Writer) Close() error

Close closes writer

func (*Writer) Write

func (w *Writer) Write(data []byte, offset, length int32) (int32, error)

Write writes data.length bytes from data to the underlying data stream.

type WriterOptions

type WriterOptions struct {
	// ContentType, if set, gives a MIME content-type for the Object.
	ContentType string
	// Metadata contains additional information about an Object. It can
	// hold arbitrary textual fields and can be retrieved together with the
	// Object. Field names can be at most 1024 bytes long. Field values are
	// not individually limited in size, but the total of all metadata
	// (fields and values) can not exceed 4 kiB.
	Metadata map[string]string
	// Expires is the time at which the new Object can expire (be deleted
	// automatically from storage nodes).
	Expires int

	// EncryptionParameters determines the cipher suite to use for
	// the Object's data encryption. If not set, the Bucket's
	// defaults will be used.
	EncryptionParameters *EncryptionParameters

	// RedundancyScheme determines the Reed-Solomon and/or Forward
	// Error Correction encoding parameters to be used for this
	// Object.
	RedundancyScheme *RedundancyScheme
}

WriterOptions controls options about writing a new Object

func NewWriterOptions

func NewWriterOptions() *WriterOptions

NewWriterOptions creates writer options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL