Documentation ¶
Index ¶
- type FileInfo
- type OS
- func (s *OS) Delete(_ context.Context, path string) error
- func (s *OS) Download(_ context.Context, path string) (io.ReadCloser, error)
- func (s *OS) Exists(_ context.Context, path string) (bool, error)
- func (s *OS) List(_ context.Context, prefix string) ([]string, error)
- func (s *OS) Stat(_ context.Context, path string) (*FileInfo, error)
- func (s *OS) Upload(_ context.Context, path string, content io.Reader) error
- type Provider
- type S3
- func (s *S3) Delete(ctx context.Context, path string) error
- func (s *S3) Download(ctx context.Context, path string) (io.ReadCloser, error)
- func (s *S3) Exists(ctx context.Context, path string) (bool, error)
- func (s *S3) List(ctx context.Context, prefix string) ([]string, error)
- func (s *S3) Stat(ctx context.Context, path string) (*FileInfo, error)
- func (s *S3) Upload(ctx context.Context, path string, content io.Reader) error
- type S3Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileInfo ¶
type FileInfo struct { // Size represents the size of the file in bytes. Size int64 // LastModified is the timestamp of when the file was last modified. LastModified time.Time // IsDir indicates whether the path represents a directory. IsDir bool // ContentType is the MIME type of the file. ContentType string }
FileInfo holds metadata about a file, such as size and last modified time.
type OS ¶
type OS struct {
BasePath string
}
OS implements the Storage interface for the local file system.
type Provider ¶
type Provider interface { // Upload stores the content from the provided io.Reader at the specified path. // It returns an error if the upload fails. Upload(ctx context.Context, path string, content io.Reader) error // Delete removes the file at the specified path. It returns an error if the // deletion fails or if the file doesn't exist. Delete(ctx context.Context, path string) error // List returns a slice of strings representing the names of files and // directories under the specified prefix. It returns an error if the listing // operation fails. List(ctx context.Context, prefix string) ([]string, error) // Download retrieves the content of the file at the specified path. It returns // an io.ReadCloser for reading the file's content and an error if the download // fails. The caller is responsible for closing the returned io.ReadCloser. Download(ctx context.Context, path string) (io.ReadCloser, error) // Exists checks if a file or directory exists at the specified path. It // returns true if the path exists, false if it doesn't, and an error if the // check fails. Exists(ctx context.Context, path string) (bool, error) // Stat retrieves metadata about the file or directory at the specified path. // It returns a FileInfo struct containing the metadata and an error if the // operation fails. Stat(ctx context.Context, path string) (*FileInfo, error) }
Provider defines the interface for file operations on different backends (e.g., S3, local filesystem).
type S3 ¶
type S3 struct {
// contains filtered or unexported fields
}
S3 implements the Storage interface for AWS S3.
func NewS3Storage ¶
NewS3Storage creates a new S3 instance with the provided configuration.
Directories ¶
Path | Synopsis |
---|---|
Package storagefakes is a generated GoMock package.
|
Package storagefakes is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.