{"modulePath":"github.com/RedAFD/code-core","version":"v1.14.0-rc8","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package storage\n\n## Variables\n\n```go\nvar (\n\t// ErrURLNotSupported represents url is not supported\n\tErrURLNotSupported = errors.New(\"url method not supported\")\n\t// ErrIterateObjectsNotSupported represents IterateObjects not supported\n\tErrIterateObjectsNotSupported = errors.New(\"iterateObjects method not supported\")\n)\n```\n\n## Functions\n\n```go\nfunc Copy(dstStorage ObjectStorage, dstPath string, srcStorage ObjectStorage, srcPath string) (int64, error)\n```\nCopy copys a file from source ObjectStorage to dest ObjectStorage\n\n```go\nfunc Init() error\n```\nInit init the stoarge\n\n```go\nfunc IsErrInvalidConfiguration(err error) bool\n```\nIsErrInvalidConfiguration checks if an error is an ErrInvalidConfiguration\n\n```go\nfunc RegisterStorageType(typ Type, fn func(ctx context.Context, cfg interface{}) (ObjectStorage, error))\n```\nRegisterStorageType registers a provided storage type with a function to create it\n\n```go\nfunc SaveFrom(objStorage ObjectStorage, p string, callback func(w io.Writer) error) error\n```\nSaveFrom saves data to the ObjectStorage with path p from the callback\n\n## Types\n\n```go\ntype ErrInvalidConfiguration struct {\n\t// contains filtered or unexported fields\n}\n```\nErrInvalidConfiguration is called when there is invalid configuration for a storage\n\n```go\nfunc (err ErrInvalidConfiguration) Error() string\n```\n\n```go\ntype LocalStorage struct {\n\t// contains filtered or unexported fields\n}\n```\nLocalStorage represents a local files storage\n\n```go\nfunc (l *LocalStorage) Delete(path string) error\n```\nDelete delete a file\n\n```go\nfunc (l *LocalStorage) IterateObjects(fn func(path string, obj Object) error) error\n```\nIterateObjects iterates across the objects in the local storage\n\n```go\nfunc (l *LocalStorage) Open(path string) (Object, error)\n```\nOpen a file\n\n```go\nfunc (l *LocalStorage) Save(path string, r io.Reader) (int64, error)\n```\nSave a file\n\n```go\nfunc (l *LocalStorage) Stat(path string) (os.FileInfo, error)\n```\nStat returns the info of the file\n\n```go\nfunc (l *LocalStorage) URL(path, name string) (*url.URL, error)\n```\nURL gets the redirect URL to a file\n\n```go\ntype LocalStorageConfig struct {\n\tPath          string `ini:\"PATH\"`\n\tTemporaryPath string `ini:\"TEMPORARY_PATH\"`\n}\n```\nLocalStorageConfig represents the configuration for a local storage\n\n```go\ntype Mappable interface {\n\tMapTo(v interface{}) error\n}\n```\nMappable represents an interface that can MapTo another interface\n\n```go\ntype MinioStorage struct {\n\t// contains filtered or unexported fields\n}\n```\nMinioStorage returns a minio bucket storage\n\n```go\nfunc (m *MinioStorage) Delete(path string) error\n```\nDelete delete a file\n\n```go\nfunc (m *MinioStorage) IterateObjects(fn func(path string, obj Object) error) error\n```\nIterateObjects iterates across the objects in the miniostorage\n\n```go\nfunc (m *MinioStorage) Open(path string) (Object, error)\n```\nOpen open a file\n\n```go\nfunc (m *MinioStorage) Save(path string, r io.Reader) (int64, error)\n```\nSave save a file to minio\n\n```go\nfunc (m *MinioStorage) Stat(path string) (os.FileInfo, error)\n```\nStat returns the stat information of the object\n\n```go\nfunc (m *MinioStorage) URL(path, name string) (*url.URL, error)\n```\nURL gets the redirect URL to a file. The presigned link is valid for 5 minutes.\n\n```go\ntype MinioStorageConfig struct {\n\tEndpoint        string `ini:\"MINIO_ENDPOINT\"`\n\tAccessKeyID     string `ini:\"MINIO_ACCESS_KEY_ID\"`\n\tSecretAccessKey string `ini:\"MINIO_SECRET_ACCESS_KEY\"`\n\tBucket          string `ini:\"MINIO_BUCKET\"`\n\tLocation        string `ini:\"MINIO_LOCATION\"`\n\tBasePath        string `ini:\"MINIO_BASE_PATH\"`\n\tUseSSL          bool   `ini:\"MINIO_USE_SSL\"`\n}\n```\nMinioStorageConfig represents the configuration for a minio storage\n\n```go\ntype NewStorageFunc func(ctx context.Context, cfg interface{}) (ObjectStorage, error)\n```\nNewStorageFunc is a function that creates a storage\n\n```go\ntype Object interface {\n\tio.ReadCloser\n\tio.Seeker\n\tStat() (os.FileInfo, error)\n}\n```\nObject represents the object on the storage\n\n```go\ntype ObjectStorage interface {\n\tOpen(path string) (Object, error)\n\tSave(path string, r io.Reader) (int64, error)\n\tStat(path string) (os.FileInfo, error)\n\tDelete(path string) error\n\tURL(path, name string) (*url.URL, error)\n\tIterateObjects(func(path string, obj Object) error) error\n}\n```\nObjectStorage represents an object storage to handle a bucket and files\n\n```go\nvar (\n\t// Attachments represents attachments storage\n\tAttachments ObjectStorage\n\n\t// LFS represents lfs storage\n\tLFS ObjectStorage\n\n\t// Avatars represents user avatars storage\n\tAvatars ObjectStorage\n\t// RepoAvatars represents repository avatars storage\n\tRepoAvatars ObjectStorage\n)\n```\n\n```go\nfunc NewLocalStorage(ctx context.Context, cfg interface{}) (ObjectStorage, error)\n```\nNewLocalStorage returns a local files\n\n```go\nfunc NewMinioStorage(ctx context.Context, cfg interface{}) (ObjectStorage, error)\n```\nNewMinioStorage returns a minio storage\n\n```go\nfunc NewStorage(typStr string, cfg interface{}) (ObjectStorage, error)\n```\nNewStorage takes a storage type and some config and returns an ObjectStorage or an error\n\n```go\ntype Type string\n```\nType is a type of Storage\n\n```go\nconst LocalStorageType Type = \"local\"\n```\nLocalStorageType is the type descriptor for local storage\n\n```go\nconst MinioStorageType Type = \"minio\"\n```\nMinioStorageType is the type descriptor for minio storage\n\n","path":"github.com/RedAFD/code-core/modules/storage","name":"storage","synopsis":"","isRedistributable":true}
