Documentation ¶
Overview ¶
Package core contains the central code for creating and reading blobs.
Index ¶
- type BlobNode
- type BlobStore
- func (bs *BlobStore) AddReaders(user auth.User, id uuid.UUID, readerAccountNames []string) (*BlobNode, error)
- func (bs *BlobStore) ChangeOwner(user auth.User, id uuid.UUID, newowner string) (*BlobNode, error)
- func (bs *BlobStore) CopyNode(user auth.User, id uuid.UUID) (*BlobNode, error)
- func (bs *BlobStore) DeleteNode(user auth.User, id uuid.UUID) error
- func (bs *BlobStore) Get(user *auth.User, id uuid.UUID) (*BlobNode, error)
- func (bs *BlobStore) GetFile(user *auth.User, id uuid.UUID, seek uint64, length uint64) (data io.ReadCloser, size int64, filename string, err error)
- func (bs *BlobStore) RemoveReaders(user auth.User, id uuid.UUID, readerAccountNames []string) (*BlobNode, error)
- func (bs *BlobStore) SetNodePublic(user auth.User, id uuid.UUID, public bool) (*BlobNode, error)
- func (bs *BlobStore) Store(le *logrus.Entry, user auth.User, data io.Reader, size int64, ...) (*BlobNode, error)
- type NoBlobError
- type UUIDGen
- type UUIDGenDefault
- type UnauthorizedACLError
- type UnauthorizedError
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlobNode ¶
type BlobNode struct { ID uuid.UUID Size int64 // ideally uint64, but ContentLength in http req is int64, so pointless MD5 values.MD5 Stored time.Time Filename string Format string Owner User Readers *[]User Public bool }
BlobNode contains basic information about a blob stored in the blobstore.
type BlobStore ¶
type BlobStore struct {
// contains filtered or unexported fields
}
BlobStore is the storage system for blobs.
func NewWithUUIDGen ¶
func NewWithUUIDGen(filestore filestore.FileStore, nodestore nodestore.NodeStore, uuidGen UUIDGen, ) *BlobStore
NewWithUUIDGen creates a new blob store with a provided UUID generator, which allows for easier testing.
func (*BlobStore) AddReaders ¶
func (bs *BlobStore) AddReaders(user auth.User, id uuid.UUID, readerAccountNames []string, ) (*BlobNode, error)
AddReaders adds readers to a node. Has no effect if the user is the node's owner or the user is already in the read ACL. Returns NoBlobError and UnauthorizedACLError.
func (*BlobStore) ChangeOwner ¶
func (bs *BlobStore) ChangeOwner(user auth.User, id uuid.UUID, newowner string, ) (*BlobNode, error)
ChangeOwner changes the owner of a node. If the new owner is in the read ACL, the new owner will be removed. Setting the new owner to the current owner has no effect. Returns NoBlobError and UnauthorizedACLError.
func (*BlobStore) CopyNode ¶
CopyNode makes a copy of the given node with an empty readers list. Returns NoBlobError and UnauthorizedError.
func (*BlobStore) DeleteNode ¶
DeleteNode deletes the given node. Returns NoBlobError and UnauthorizedError.
func (*BlobStore) GetFile ¶
func (bs *BlobStore) GetFile(user *auth.User, id uuid.UUID, seek uint64, length uint64, ) (data io.ReadCloser, size int64, filename string, err error)
GetFile gets the file from a node. seek and length determine the byte range of the file returned. Passing 0 for length implies the remainder of the file should be returned. seeking beyond the file length will return an error, but requesting a file longer than the actual length is accepted and will return the remainder of the file. Returns NoBlobError, UnauthorizedError, and IllegalInputError.
func (*BlobStore) RemoveReaders ¶
func (bs *BlobStore) RemoveReaders(user auth.User, id uuid.UUID, readerAccountNames []string, ) (*BlobNode, error)
RemoveReaders removes readers from a node. Has no effect if the user is not already in the read ACL. Returns NoBlobError and UnauthorizedACLError.
func (*BlobStore) SetNodePublic ¶
SetNodePublic sets whether a node can be read by anyone, including anonymous users. Returns NoBlobError and UnauthorizedACLError.
type NoBlobError ¶
type NoBlobError string
NoBlobError is returned when a requested blob does not exist.
func NewNoBlobError ¶
func NewNoBlobError(err string) *NoBlobError
NewNoBlobError creates a new NoBlobError.
func (*NoBlobError) Error ¶
func (e *NoBlobError) Error() string
type UUIDGenDefault ¶
type UUIDGenDefault struct{}
UUIDGenDefault generates uuids via the uuid.New() method.
func (*UUIDGenDefault) GetUUID ¶
func (u *UUIDGenDefault) GetUUID() uuid.UUID
GetUUID generates a random UUID.
type UnauthorizedACLError ¶
type UnauthorizedACLError string
UnauthorizedACLError is returned when a user may not alter a blob's ACLs in the manner requested.
func NewUnauthorizedACLError ¶
func NewUnauthorizedACLError(err string) *UnauthorizedACLError
NewUnauthorizedACLError creates a new UnauthorizedACLError.
func (*UnauthorizedACLError) Error ¶
func (e *UnauthorizedACLError) Error() string
type UnauthorizedError ¶
type UnauthorizedError string
UnauthorizedError is returned when a user may not read a blob.
func NewUnauthorizedError ¶
func NewUnauthorizedError(err string) *UnauthorizedError
NewUnauthorizedError creates a new UnauthorizedError.
func (*UnauthorizedError) Error ¶
func (e *UnauthorizedError) Error() string