object

package
v0.0.0-...-1dc401f Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package object defines some useful Objects

Index

Constants

This section is empty.

Variables

View Source
var MemoryFs memoryFs

MemoryFs is an in memory Fs, it only supports FsInfo and Put

Functions

This section is empty.

Types

type MemoryObject

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

MemoryObject is an in memory object

func NewMemoryObject

func NewMemoryObject(remote string, modTime time.Time, content []byte) *MemoryObject

NewMemoryObject returns an in memory Object with the modTime and content passed in

func (*MemoryObject) Content

func (o *MemoryObject) Content() []byte

Content returns the underlying buffer

func (*MemoryObject) Fs

func (o *MemoryObject) Fs() fs.Info

Fs returns read only access to the Fs that this object is part of

func (*MemoryObject) Hash

func (o *MemoryObject) Hash(ctx context.Context, h hash.Type) (string, error)

Hash returns the requested hash of the contents

func (*MemoryObject) Metadata

func (o *MemoryObject) Metadata(ctx context.Context) (fs.Metadata, error)

Metadata on the object

func (*MemoryObject) ModTime

func (o *MemoryObject) ModTime(ctx context.Context) time.Time

ModTime returns the modification date of the file

func (*MemoryObject) Open

func (o *MemoryObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)

Open opens the file for read. Call Close() on the returned io.ReadCloser

func (*MemoryObject) Remote

func (o *MemoryObject) Remote() string

Remote returns the remote path

func (*MemoryObject) Remove

func (o *MemoryObject) Remove(ctx context.Context) error

Remove this object

func (*MemoryObject) SetFs

func (o *MemoryObject) SetFs(f fs.Fs) *MemoryObject

SetFs sets the Fs that this memory object thinks it is part of It will ignore nil f

func (*MemoryObject) SetModTime

func (o *MemoryObject) SetModTime(ctx context.Context, modTime time.Time) error

SetModTime sets the metadata on the object to set the modification date

func (*MemoryObject) Size

func (o *MemoryObject) Size() int64

Size returns the size of the file

func (*MemoryObject) Storable

func (o *MemoryObject) Storable() bool

Storable says whether this object can be stored

func (*MemoryObject) String

func (o *MemoryObject) String() string

String returns a description of the Object

func (*MemoryObject) Update

func (o *MemoryObject) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error)

Update in to the object with the modTime given of the given size

This re-uses the internal buffer if at all possible.

func (*MemoryObject) WithMetadata

func (o *MemoryObject) WithMetadata(meta fs.Metadata) *MemoryObject

WithMetadata adds meta to the MemoryObject

type StaticObjectInfo

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

StaticObjectInfo is an ObjectInfo which can be constructed from scratch

func NewStaticObjectInfo

func NewStaticObjectInfo(remote string, modTime time.Time, size int64, storable bool, hashes map[hash.Type]string, f fs.Info) *StaticObjectInfo

NewStaticObjectInfo returns a static ObjectInfo If hashes is nil and fs is not nil, the hash map will be replaced with empty hashes of the types supported by the fs.

func (*StaticObjectInfo) Fs

func (i *StaticObjectInfo) Fs() fs.Info

Fs returns read only access to the Fs that this object is part of

func (*StaticObjectInfo) Hash

func (i *StaticObjectInfo) Hash(ctx context.Context, h hash.Type) (string, error)

Hash returns the requested hash of the contents

func (*StaticObjectInfo) Metadata

func (i *StaticObjectInfo) Metadata(ctx context.Context) (fs.Metadata, error)

Metadata on the object

func (*StaticObjectInfo) MimeType

func (i *StaticObjectInfo) MimeType(ctx context.Context) string

MimeType returns the content type of the Object if known, or "" if not

func (*StaticObjectInfo) ModTime

func (i *StaticObjectInfo) ModTime(ctx context.Context) time.Time

ModTime returns the modification date of the file

func (*StaticObjectInfo) Remote

func (i *StaticObjectInfo) Remote() string

Remote returns the remote path

func (*StaticObjectInfo) Size

func (i *StaticObjectInfo) Size() int64

Size returns the size of the file

func (*StaticObjectInfo) Storable

func (i *StaticObjectInfo) Storable() bool

Storable says whether this object can be stored

func (*StaticObjectInfo) String

func (i *StaticObjectInfo) String() string

String returns a description of the Object

func (*StaticObjectInfo) WithMetadata

func (i *StaticObjectInfo) WithMetadata(meta fs.Metadata) *StaticObjectInfo

WithMetadata adds meta to the ObjectInfo

func (*StaticObjectInfo) WithMimeType

func (i *StaticObjectInfo) WithMimeType(mimeType string) *StaticObjectInfo

WithMimeType adds meta to the ObjectInfo

Jump to

Keyboard shortcuts

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