Documentation
¶
Index ¶
- func FileSize(f *os.File) int64
- func StringMd5(s string) string
- type DirInfo
- type UpYun
- func (u *UpYun) DeleteFile(file string) error
- func (u *UpYun) GetBucketUsage() (float64, error)
- func (u *UpYun) GetFileInfo(file string) map[string]string
- func (u *UpYun) GetFolderUsage(path string) (float64, error)
- func (u *UpYun) GetWritedFileInfo(key string) string
- func (u *UpYun) MkDir(path string, autoMkdir bool) error
- func (u *UpYun) ReadDir(path string) ([]*DirInfo, error)
- func (u *UpYun) ReadFile(file string, outFile *os.File) error
- func (u *UpYun) RmDir(dir string) error
- func (u *UpYun) SetApiDomain(domain string)
- func (u *UpYun) SetContentMD5(str string)
- func (u *UpYun) SetFileSecret(str string)
- func (u *UpYun) SetTimeout(time int)
- func (u *UpYun) Version() string
- func (u *UpYun) WriteFile(filePath string, inFile *os.File, autoMkdir bool) error
- type UpyunConfig
- type UpyunUploader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type UpYun ¶
func NewUpYun ¶
*
- 初始化 UpYun 存储接口
- @param bucketName 空间名称
- @param userName 操作员名称
- @param passWord 密码
- return UpYun object
func (*UpYun) GetFileInfo ¶
*
- 获取文件信息
- @param file 文件路径(包含文件名)
- return array('type': file | folder, 'size': file size, 'date': unix time) 或 nil
func (*UpYun) GetWritedFileInfo ¶
*
- 获取上传文件后的信息(仅图片空间有返回数据)
- @param key 信息字段名(x-upyun-width、x-upyun-height、x-upyun-frames、x-upyun-file-type)
- return string or ""
func (*UpYun) ReadFile ¶
*
- 读取文件
- @param file 文件路径(包含文件名)
- @param outFile 可传递文件IO数据流(结果返回true or false)
- return error
func (*UpYun) SetApiDomain ¶
* * 切换 API 接口的域名 * @param domain { 默认 v0.api.upyun.com 自动识别,
v1.api.upyun.com 电信, v2.api.upyun.com 联通, v3.api.upyun.com 移动 }
* return 无
func (*UpYun) SetContentMD5 ¶
*
- 设置待上传文件的 Content-MD5 值(如又拍云服务端收到的文件MD5值与用户设置的不一致,
- 将回报 406 Not Acceptable 错误)
- @param str (文件 MD5 校验码)
- return 无
func (*UpYun) SetFileSecret ¶
*
- 设置待上传文件的 访问密钥(注意:仅支持图片空!,设置密钥后,无法根据原文件URL直接访问,需带 URL 后面加上 (缩略图间隔标志符+密钥) 进行访问)
- 如缩略图间隔标志符为 ! ,密钥为 bac,上传文件路径为 /folder/test.jpg ,那么该图片的对外访问地址为: http://空间域名/folder/test.jpg!bac
- @param $str (文件 MD5 校验码)
- return null;
type UpyunConfig ¶
type UpyunConfig struct { Host string `toml:"host" mapstructure:"host" validate:"nonzero"` BucketName string `toml:"bucket_name" mapstructure:"bucket_name" validate:"nonzero"` UserName string `toml:"user_name" mapstructure:"user_name" validate:"nonzero"` PassWord string `toml:"pass_word" mapstructure:"pass_word" validate:"nonzero"` }
type UpyunUploader ¶
type UpyunUploader struct {
Config UpyunConfig
}
func (*UpyunUploader) PutFile ¶
func (u *UpyunUploader) PutFile(localPath, targetPath string) (err error)
Click to show internal directories.
Click to hide internal directories.