Documentation
¶
Overview ¶
Package file provides various functionalities for reading, writing and manipulating files and supports different file storage backends like aws, azure, gcp, sftp, ftp along with the support for local files.
Index ¶
Constants ¶
View Source
const ( Local = "LOCAL" Azure = "AZURE" AWS = "AWS" GCP = "GCP" SFTP = "SFTP" FTP = "FTP" )
View Source
const ( READ = Mode("r") WRITE = Mode("w") READWRITE = Mode("rw") APPEND = Mode("a") )
View Source
const ErrListingNotSupported = errors.Error(`Listing not supported for provided file store.` +
` Please set a valid value of FILE_STORE:{LOCAL or SFTP}`)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AzureConfig ¶
type AzureConfig struct {
AccountName string
AccessKey string
ContainerName string
BlockSize string
Parallelism string
}
AzureConfig is used to store configurations related to Azure cloud storage.
type Config ¶
type Config struct {
FileStore string
Azure AzureConfig
AWS AWSConfig
GCP GCPConfig
SFTP SFTPConfig
FTP FTPConfig
}
Config is redefined in this package similar to what defined in gofr package.
type FTPConfig ¶
type FTPConfig struct {
Host string
User string
Password string
Port int
RetryDuration time.Duration
}
FTPConfig is used to store configuration related to FTP.
type File ¶
type File interface {
// Open should open the file in the provided mode. Implementation depends on the file storage to be used.
Open() error
// Read calls the internal file descriptor method to Read.
Read([]byte) (int, error)
// Write calls the internal file descriptor method to Write.
Write([]byte) (int, error)
// Seek calls the internal file descriptor method to Seek
Seek(offset int64, whence int) (int64, error)
// Close calls the internal file descriptor method to Close.
Close() error
}
type S3Client ¶
type S3Client interface {
GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}
S3Client is an interface for interacting with AWS S3.
type SFTPConfig ¶
SFTPConfig is used to store configuration related to SFTP.
type Storage ¶
type Storage interface {
File
// List lists all the files in the directory
List(directory string) ([]string, error)
// Move moves the file from source to destination
Move(src, dest string) error
// Copy copies the file from source to destination
Copy(src, dest string) (int, error)
// Delete deletes the given file
Delete(fileName string) error
}
Click to show internal directories.
Click to hide internal directories.