Documentation ¶
Overview ¶
Package s3 provides an endpoint for connecting to Amazon S3 or an S3-compatible storage
Index ¶
- Constants
- Variables
- func CopyObjectMultipart(ctx context.Context, client *minio.Core, srcObject minio.ObjectInfo, ...) error
- type ChecksumMapper
- type Client
- func (c *Client) ComputeChecksum(node *tree.Node) error
- func (c *Client) CreateNode(ctx context.Context, node *tree.Node, updateIfExists bool) (err error)
- func (c *Client) DeleteNode(ctx context.Context, path string) (err error)
- func (c *Client) GetEndpointInfo() model.EndpointInfo
- func (c *Client) GetReaderOn(path string) (out io.ReadCloser, err error)
- func (c *Client) GetWriterOn(cancel context.Context, path string, targetSize int64) (out io.WriteCloser, writeDone chan bool, writeErr chan error, err error)
- func (c *Client) LoadNode(ctx context.Context, path string, extendedStats ...bool) (node *tree.Node, err error)
- func (c *Client) MoveNode(ctx context.Context, oldPath string, newPath string) (err error)
- func (c *Client) SetChecksumMapper(mapper ChecksumMapper, purgeAfterWalk bool)
- func (c *Client) SetPlainSizeComputer(computer func(nodeUUID string) (int64, error))
- func (c *Client) SetServerRequiresNormalization()
- func (c *Client) SkipRecomputeEtagByCopy()
- func (c *Client) Stat(pa string) (i os.FileInfo, err error)
- func (c *Client) UpdateNodeUuid(ctx context.Context, node *tree.Node) (*tree.Node, error)
- func (c *Client) Walk(walknFc model.WalkNodesFunc, root string, recursive bool) (err error)
- func (c *Client) Watch(recursivePath string) (*model.WatchObject, error)
- type MemChecksumMapper
- type MinioClientMock
- func (c *MinioClientMock) BucketExists(context.Context, string) (bool, error)
- func (c *MinioClientMock) CopyObject(ctx context.Context, dst minio.CopyDestOptions, src minio.CopySrcOptions) (u minio.UploadInfo, e error)
- func (c *MinioClientMock) GetBucketTagging(_ context.Context, bucketName string) (tt *tags.Tags, e error)
- func (c *MinioClientMock) GetObject(_ context.Context, bucket string, path string, opts minio.GetObjectOptions) (object *minio.Object, err error)
- func (c *MinioClientMock) ListBuckets(_ context.Context) (bb []minio.BucketInfo, e error)
- func (c *MinioClientMock) ListObjects(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo
- func (c *MinioClientMock) ListenBucketNotification(ctx context.Context, bucketName, prefix, suffix string, events []string) <-chan notification.Info
- func (c *MinioClientMock) PutObject(_ context.Context, bucket string, path string, reader io.Reader, size int64, ...) (ui minio.UploadInfo, err error)
- func (c *MinioClientMock) RemoveObject(ctx context.Context, bucketName, objectName string, ...) error
- func (c *MinioClientMock) StatObject(_ context.Context, bucket string, path string, opts minio.StatObjectOptions) (minio.ObjectInfo, error)
- type MockableMinio
- type MultiBucketClient
- func (m *MultiBucketClient) ComputeChecksum(node *tree.Node) (err error)
- func (m *MultiBucketClient) CreateNode(ctx context.Context, node *tree.Node, updateIfExists bool) (err error)
- func (m *MultiBucketClient) DeleteNode(ctx context.Context, path string) (err error)
- func (m *MultiBucketClient) GetEndpointInfo() model.EndpointInfo
- func (m *MultiBucketClient) GetReaderOn(path string) (out io.ReadCloser, err error)
- func (m *MultiBucketClient) GetWriterOn(cancel context.Context, path string, targetSize int64) (out io.WriteCloser, writeDone chan bool, writeErr chan error, err error)
- func (m *MultiBucketClient) LoadNode(ctx context.Context, p string, extendedStats ...bool) (node *tree.Node, err error)
- func (m *MultiBucketClient) MoveNode(ctx context.Context, oldPath string, newPath string) (err error)
- func (m *MultiBucketClient) ProvidesMetadataNamespaces() (out []glob.Glob, o bool)
- func (m *MultiBucketClient) SetChecksumMapper(cs ChecksumMapper)
- func (m *MultiBucketClient) SetPlainSizeComputer(computer func(nodeUUID string) (int64, error))
- func (m *MultiBucketClient) SetServerRequiresNormalization()
- func (m *MultiBucketClient) SkipRecomputeEtagByCopy()
- func (m *MultiBucketClient) UpdateNodeUuid(ctx context.Context, node *tree.Node) (n *tree.Node, err error)
- func (m *MultiBucketClient) Walk(walknFc model.WalkNodesFunc, root string, recursive bool) (err error)
- func (m *MultiBucketClient) Watch(recursivePath string) (*model.WatchObject, error)
- type S3FileInfo
Constants ¶
const MaxCopyObjectSize = 1024 * 1024 * 1024 * 5
MaxCopyObjectSize is 5GB => if greater, we have to switch to multipart
Variables ¶
var ( UserAgentAppName = "pydio.sync.client.s3" UserAgentVersion = "1.0" )
Functions ¶
Types ¶
type ChecksumMapper ¶
type ChecksumMapper interface { // Get finds a checksum for a given eTag, returns false if not found Get(eTag string) (string, bool) // Set stores an eTag checksum couple if it does not already exists Set(eTag, checksum string) // Purge removes unknown values based on the full list of know values Purge(knownETags []string) int }
ChecksumMapper maintains a mapping of eTags => checksum
type Client ¶
type Client struct { Mc MockableMinio Bucket string RootPath string Host string ServerRequiresNormalization bool // contains filtered or unexported fields }
Client wraps a Minio Client to speak with an S3-compatible backend
func (*Client) CreateNode ¶
func (*Client) DeleteNode ¶
func (*Client) GetEndpointInfo ¶
func (c *Client) GetEndpointInfo() model.EndpointInfo
func (*Client) GetReaderOn ¶
func (c *Client) GetReaderOn(path string) (out io.ReadCloser, err error)
func (*Client) GetWriterOn ¶
func (*Client) SetChecksumMapper ¶
func (c *Client) SetChecksumMapper(mapper ChecksumMapper, purgeAfterWalk bool)
SetChecksumMapper passes a ChecksumMapper storage that will prevent in-place copy of objects or metadata modification and store md5 for a given eTag locally instead.
func (*Client) SetPlainSizeComputer ¶
SetPlainSizeComputer passes a computer function to extract plain size from an encrypted node
func (*Client) SetServerRequiresNormalization ¶
func (c *Client) SetServerRequiresNormalization()
SetServerRequiresNormalization is used on MacOS to normalize UTF-8 chars to/from NFC/NFD
func (*Client) SkipRecomputeEtagByCopy ¶
func (c *Client) SkipRecomputeEtagByCopy()
SkipRecomputeEtagByCopy sets a special behavior to avoir recomputing etags by in-place copying objects on storages that do not support this feature
func (*Client) UpdateNodeUuid ¶
UpdateNodeUuid makes this endpoint an UuidReceiver
type MemChecksumMapper ¶
type MemChecksumMapper struct {
// contains filtered or unexported fields
}
MemChecksumMapper is an in-memory implementation for ChecksumMapper interface
func NewMemChecksumMapper ¶
func NewMemChecksumMapper() *MemChecksumMapper
NewMemChecksumMapper instantiates a new ChecksumMapper
func (*MemChecksumMapper) Get ¶
func (m *MemChecksumMapper) Get(eTag string) (string, bool)
Get finds a checksum by eTag
func (*MemChecksumMapper) Purge ¶
func (m *MemChecksumMapper) Purge(knownETags []string) int
Purge compares existing eTags to stored eTags and removes unnecessary ones
func (*MemChecksumMapper) Set ¶
func (m *MemChecksumMapper) Set(eTag, checksum string)
Set stores a checksum for a given eTag
type MinioClientMock ¶
type MinioClientMock struct {
// contains filtered or unexported fields
}
func (*MinioClientMock) BucketExists ¶
func (*MinioClientMock) CopyObject ¶
func (c *MinioClientMock) CopyObject(ctx context.Context, dst minio.CopyDestOptions, src minio.CopySrcOptions) (u minio.UploadInfo, e error)
func (*MinioClientMock) GetBucketTagging ¶
func (*MinioClientMock) GetObject ¶
func (c *MinioClientMock) GetObject(_ context.Context, bucket string, path string, opts minio.GetObjectOptions) (object *minio.Object, err error)
func (*MinioClientMock) ListBuckets ¶
func (c *MinioClientMock) ListBuckets(_ context.Context) (bb []minio.BucketInfo, e error)
func (*MinioClientMock) ListObjects ¶
func (c *MinioClientMock) ListObjects(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo
func (*MinioClientMock) ListenBucketNotification ¶
func (c *MinioClientMock) ListenBucketNotification(ctx context.Context, bucketName, prefix, suffix string, events []string) <-chan notification.Info
func (*MinioClientMock) PutObject ¶
func (c *MinioClientMock) PutObject(_ context.Context, bucket string, path string, reader io.Reader, size int64, opts minio.PutObjectOptions) (ui minio.UploadInfo, err error)
func (*MinioClientMock) RemoveObject ¶
func (c *MinioClientMock) RemoveObject(ctx context.Context, bucketName, objectName string, opts minio.RemoveObjectOptions) error
func (*MinioClientMock) StatObject ¶
func (c *MinioClientMock) StatObject(_ context.Context, bucket string, path string, opts minio.StatObjectOptions) (minio.ObjectInfo, error)
type MockableMinio ¶
type MockableMinio interface { ListBuckets(ctx context.Context) ([]minio.BucketInfo, error) BucketExists(context.Context, string) (bool, error) GetBucketTagging(context.Context, string) (*tags.Tags, error) StatObject(ctx context.Context, bucket string, path string, opts minio.StatObjectOptions) (minio.ObjectInfo, error) GetObject(ctx context.Context, bucket string, path string, opts minio.GetObjectOptions) (object *minio.Object, err error) ListObjects(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo RemoveObject(ctx context.Context, bucketName, objectName string, opts minio.RemoveObjectOptions) error PutObject(ctx context.Context, bucket string, path string, reader io.Reader, size int64, opts minio.PutObjectOptions) (ui minio.UploadInfo, err error) CopyObject(ctx context.Context, dst minio.CopyDestOptions, src minio.CopySrcOptions) (minio.UploadInfo, error) ListenBucketNotification(ctx context.Context, bucketName, prefix, suffix string, events []string) <-chan notification.Info }
type MultiBucketClient ¶
type MultiBucketClient struct {
// contains filtered or unexported fields
}
func NewMultiBucketClient ¶
func NewMultiBucketClient(ctx context.Context, host string, key string, secret string, secure bool, options model.EndpointOptions, bucketsFilter string) (*MultiBucketClient, error)
NewMultiBucketClient creates an s3 wrapped client that lists buckets as top level folders
func (*MultiBucketClient) ComputeChecksum ¶
func (m *MultiBucketClient) ComputeChecksum(node *tree.Node) (err error)
func (*MultiBucketClient) CreateNode ¶
func (*MultiBucketClient) DeleteNode ¶
func (m *MultiBucketClient) DeleteNode(ctx context.Context, path string) (err error)
func (*MultiBucketClient) GetEndpointInfo ¶
func (m *MultiBucketClient) GetEndpointInfo() model.EndpointInfo
func (*MultiBucketClient) GetReaderOn ¶
func (m *MultiBucketClient) GetReaderOn(path string) (out io.ReadCloser, err error)
func (*MultiBucketClient) GetWriterOn ¶
func (m *MultiBucketClient) GetWriterOn(cancel context.Context, path string, targetSize int64) (out io.WriteCloser, writeDone chan bool, writeErr chan error, err error)
func (*MultiBucketClient) ProvidesMetadataNamespaces ¶
func (m *MultiBucketClient) ProvidesMetadataNamespaces() (out []glob.Glob, o bool)
ProvidesMetadataNamespaces implements MetadataProvider interface
func (*MultiBucketClient) SetChecksumMapper ¶
func (m *MultiBucketClient) SetChecksumMapper(cs ChecksumMapper)
func (*MultiBucketClient) SetPlainSizeComputer ¶
func (m *MultiBucketClient) SetPlainSizeComputer(computer func(nodeUUID string) (int64, error))
func (*MultiBucketClient) SetServerRequiresNormalization ¶
func (m *MultiBucketClient) SetServerRequiresNormalization()
func (*MultiBucketClient) SkipRecomputeEtagByCopy ¶
func (m *MultiBucketClient) SkipRecomputeEtagByCopy()
SkipRecomputeEtagByCopy sets a special behavior to avoir recomputing etags by in-place copying objects on storages that do not support this feature
func (*MultiBucketClient) UpdateNodeUuid ¶
func (*MultiBucketClient) Walk ¶
func (m *MultiBucketClient) Walk(walknFc model.WalkNodesFunc, root string, recursive bool) (err error)
func (*MultiBucketClient) Watch ¶
func (m *MultiBucketClient) Watch(recursivePath string) (*model.WatchObject, error)
type S3FileInfo ¶
type S3FileInfo struct { Object minio.ObjectInfo // contains filtered or unexported fields }
func NewS3FileInfo ¶
func NewS3FileInfo(object minio.ObjectInfo) *S3FileInfo
func NewS3FolderInfo ¶
func NewS3FolderInfo(object minio.ObjectInfo) *S3FileInfo
func (*S3FileInfo) IsDir ¶
func (s *S3FileInfo) IsDir() bool
IsDir is an abbreviation for Mode().IsDir()
func (*S3FileInfo) ModTime ¶
func (s *S3FileInfo) ModTime() time.Time
ModTime retuns modification time
func (*S3FileInfo) Size ¶
func (s *S3FileInfo) Size() int64
Size gets length in bytes for regular files; system-dependent for others
func (*S3FileInfo) Sys ¶
func (s *S3FileInfo) Sys() interface{}
Sys returns underlying data source (can return nil)