storj/lib/uplink/objects.go
Dylan Lott 6bf46e80ee
Adds Libuplink (#1452)
* Merge in upstream

* Some initial wireup

* Added common.go file, more misc. work

* WIP adding identity in

* Get FullIdentity combined into Uplink

* Structure libuplink a little better

* Update some types and add some comments

* WIP uplink stuff

* Get uplink types and configs figured out

* add initial setup for tests, happy path is working

* Remove dependency from miniogw

* Adds miniogw code and wires it up correctly

* WIP working on getting test suite setup

* Uplink client now returns successfully and passes some initial happy path tets

* WIP trying to get v2 draft ready

* WIP

* WIP wiring up bucket methods and adjusting to some review feedback

* Getting closer to v2 libuplink draft

* CreateBucket now works and has tests to prove it

* Bucket tests are passing now

* removing some code

* Updates error handling and linter fixes

* Removes main_test

* Uploads and downloads are now working

* Rename BucketOpts to Encryption

* updates

* added test file back to git that was being ignored for some reason

* more test conditions

* changes Checksum in ObjectMeta struct to be type []byte

* linter fix

* Updates how encryption is passed through to bucket opts

* Updates encryption handling at bucket and access level

* Fixes imports

* Updates per code review
2019-03-20 09:43:53 -06:00

85 lines
2.1 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package uplink
import (
"context"
"io"
"time"
"storj.io/storj/pkg/storj"
)
// Object holds the information for a given object
type Object struct {
Meta ObjectMeta
}
// ObjectMeta represents metadata about a specific Object
type ObjectMeta struct {
Bucket string
Path storj.Path
IsPrefix bool
Metadata map[string]string
Created time.Time
Modified time.Time
Expires time.Time
Size int64
Checksum []byte
}
// UploadOpts controls options about uploading a new Object, if authorized.
type UploadOpts struct {
Metadata map[string]string
Expires time.Time
Encryption *Encryption
}
// ListObjectsField numbers the fields of list objects
type ListObjectsField int
const (
// ListObjectsMetaNone opts
ListObjectsMetaNone ListObjectsField = 0
// ListObjectsMetaModified opts
ListObjectsMetaModified ListObjectsField = 1 << iota
// ListObjectsMetaExpiration opts
ListObjectsMetaExpiration ListObjectsField = 1 << iota
// ListObjectsMetaSize opts
ListObjectsMetaSize ListObjectsField = 1 << iota
// ListObjectsMetaChecksum opts
ListObjectsMetaChecksum ListObjectsField = 1 << iota
// ListObjectsMetaUserDefined opts
ListObjectsMetaUserDefined ListObjectsField = 1 << iota
// ListObjectsMetaAll opts
ListObjectsMetaAll ListObjectsField = 1 << iota
)
// ListObjectsConfig holds params for listing objects with the Gateway
type ListObjectsConfig struct {
// this differs from storj.ListOptions by removing the Delimiter field
// (ours is hardcoded as "/"), and adding the Fields field to optionally
// support efficient listing that doesn't require looking outside of the
// path index in pointerdb.
Prefix storj.Path
Cursor storj.Path
Recursive bool
Direction storj.ListDirection
Limit int
Fields ListObjectsFields
}
// ListObjectsFields is an interface that I haven't figured out yet
type ListObjectsFields interface{}
// Range returns an objects data
func (o *Object) Range(ctx context.Context, offset, length int64) (io.ReadCloser, error) {
panic("TODO")
}