Documentation ¶
Index ¶
- Constants
- Variables
- func Base64Decode(s string) ([]byte, error)
- func Base64Encode(src []byte) string
- func Base64Reader(fi io.Reader) (string, error)
- func BucketURLMake(cdn, endpoint, bucket string) (*url.URL, error)
- func Md5Reader(fr io.Reader) (string, error)
- func Md5String(str string) string
- func PublicURLMake(domain, key string) (*url.URL, error)
- func PublicURLRead(publicURL string) ([]byte, error)
- func Sha1String(str string) string
- func Sha256String(str string) string
- type AbstractAdapter
- type FsManage
- func (f *FsManage) Adapter(disk string) (IAdapter, error)
- func (f *FsManage) Copy(source, destination string) (bool, error)
- func (f *FsManage) Delete(path string) (int64, error)
- func (f *FsManage) DiskExist(disk string) bool
- func (f *FsManage) Disks() []string
- func (f *FsManage) Exist(path string) (bool, error)
- func (f *FsManage) Extend(adapter IAdapter, names ...string) *FsManage
- func (f *FsManage) ExtendConfigPtr(config any) error
- func (f *FsManage) MimeType(path string) (string, error)
- func (f *FsManage) Move(source, destination string) (bool, error)
- func (f *FsManage) Read(path string) ([]byte, error)
- func (f *FsManage) Size(path string) (int64, error)
- func (f *FsManage) URL(path string) (*url.URL, error)
- func (f *FsManage) Update(path string, contents []byte) error
- func (f *FsManage) UpdateStream(path, resource string) error
- func (f *FsManage) Write(path string, contents []byte) error
- func (f *FsManage) WriteReader(path string, reader io.Reader) error
- func (f *FsManage) WriteStream(path, resource string) error
- type IAdapter
- type IAdapterConfig
- type IFS
Constants ¶
View Source
const ( DiskNameLocal = "LOCAL" DiskNameOSS = "OSS" DiskNameCOS = "COS" DiskNameBOS = "BOS" DiskNameGoogleCloudCloudStorage = "CloudStorage" DiskNameQiNiuKoDo = "KODO" HeaderGetLength = "content-length" HeaderGetContentType = "content-type" PathTypeFile = "file" PathTypeDirectory = "directory" ModePublicString = "public" ModePrivateString = "private" ModeFilePublic = 0644 ModeFilePrivate = 0600 ModeDirPublic = 0755 ModeDirPrivate = 0700 )
Variables ¶
View Source
var ( ConfigPtrTag = "gfs" ConfigPtrSplitTagDefaultDisk = "default" )
View Source
var ( FileModes = map[string]map[string]os.FileMode{ PathTypeFile: { ModePublicString: ModeFilePublic, ModePrivateString: ModeFilePrivate, }, PathTypeDirectory: { ModePublicString: ModeDirPublic, ModePrivateString: ModeDirPrivate, }, } )
Functions ¶
func Base64Decode ¶ added in v0.1.2
func Base64Encode ¶ added in v0.1.2
func Base64Reader ¶ added in v0.1.2
Base64Reader f, _ := os.Open("./_example/1.jpeg") f.Seek(0, 0) gfs.Base64Reader(f)
func Md5Reader ¶ added in v0.1.2
Md5Reader f, _ := os.Open("./_example/1.jpeg") f.Seek(0, 0) gfs.Md5Reader(f)
func PublicURLRead ¶
func Sha1String ¶ added in v0.1.2
func Sha256String ¶ added in v0.1.2
Types ¶
type AbstractAdapter ¶
type AbstractAdapter struct {
// contains filtered or unexported fields
}
func (*AbstractAdapter) ApplyPathPrefix ¶
func (a *AbstractAdapter) ApplyPathPrefix(path string) string
func (*AbstractAdapter) SetPathPrefix ¶
func (a *AbstractAdapter) SetPathPrefix(prefix string)
type FsManage ¶
type FsManage struct {
// contains filtered or unexported fields
}
func (*FsManage) ExtendConfigPtr ¶
func (*FsManage) UpdateStream ¶
func (*FsManage) WriteStream ¶
type IAdapterConfig ¶
type IFS ¶
type IFS interface { // Bucket Reselect Bucket Bucket(bucket string) IAdapter URL(path string) (*url.URL, error) // Exist Determine if the file exists Exist(path string) (bool, error) // WriteReader write file content and return full path WriteReader(path string, reader io.Reader) error // Write file content and return full path Write(path string, contents []byte) error // WriteStream Resource file write returns full path WriteStream(path, resource string) error // Read Read file Read(path string) ([]byte, error) // Delete Deleting files returns the number of deleted files Delete(path string) (int64, error) // Size Get File Size Size(path string) (int64, error) // Update the file content and return the updated full path Update(path string, contents []byte) error // UpdateStream Return the updated full path based on resource file updates UpdateStream(path, resource string) error // MimeType Get File MimeType MimeType(path string) (string, error) // Move move file Move(source, destination string) (bool, error) // Copy copy file Copy(source, destination string) (bool, error) }
Click to show internal directories.
Click to hide internal directories.