Documentation
¶
Index ¶
- func CreateProgressBar(percentage, width int) string
- func FormatBytes(bytes int64) string
- func FormatDuration(d time.Duration) string
- type APIError
- type BatchUploadRequest
- type BatchUploadResult
- type Client
- func (c *Client) BatchUpload(req *BatchUploadRequest) (*BatchUploadResult, error)
- func (c *Client) CopyFile(req *CopyFileRequest) error
- func (c *Client) CreateBucket(req *CreateBucketRequest) error
- func (c *Client) DeleteBucket(bucketName string) error
- func (c *Client) DeleteFile(bucket, key string) error
- func (c *Client) GetBucketDomains(bucketName string) ([]string, error)
- func (c *Client) GetFileInfo(bucket, key string) (*FileInfo, error)
- func (c *Client) GetFileURL(bucket, key string, expires time.Duration) (string, error)
- func (c *Client) ListBuckets(tagCondition string, shared bool) ([]string, error)
- func (c *Client) ListFiles(req *ListFilesRequest) (*ListFilesResult, error)
- func (c *Client) MoveFile(req *MoveFileRequest) error
- func (c *Client) Ping() error
- func (c *Client) SetBucketPrivate(req *SetBucketPrivateRequest) error
- func (c *Client) UploadBytes(req *UploadBytesRequest) (*UploadResult, error)
- func (c *Client) UploadFile(req *UploadRequest) (*UploadResult, error)
- func (c *Client) UploadFromReader(req *UploadFromReaderRequest) (*UploadResult, error)
- type Config
- type CopyFileRequest
- type CreateBucketRequest
- type FileInfo
- type ListFilesRequest
- type ListFilesResult
- type MoveFileRequest
- type ProgressMonitor
- type SetBucketPrivateRequest
- type UploadBytesRequest
- type UploadError
- type UploadFromReaderRequest
- type UploadRequest
- type UploadResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateProgressBar ¶
CreateProgressBar 创建进度条
func FormatDuration ¶
Types ¶
type APIError ¶
type APIError struct {
StatusCode int `json:"statusCode"`
Message string `json:"message"`
Details string `json:"details"`
}
APIError API Error
type BatchUploadRequest ¶
type BatchUploadRequest struct {
Files []string // file list
Bucket string // bucket name
KeyPrefix string // key prefix
AllowedTypes []string // all types
Compress bool // if compress file
Quality int // quality 1-100 - default 100
Watermark bool // if watermark
WatermarkText string // watermark text
WatermarkPosition string // watermark position
OnProgress func(completed, total int, current string) // batch upload progress callback
OnFileProgress func(uploaded, total int64) // signal file upload progress
}
BatchUploadRequest batch upload request
type BatchUploadResult ¶
type BatchUploadResult struct {
Success []UploadResult `json:"success"`
Failed []UploadError `json:"failed"`
Total int `json:"total"`
}
BatchUploadResult batch upload result
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client LingStorage SDK Client
func (*Client) BatchUpload ¶
func (c *Client) BatchUpload(req *BatchUploadRequest) (*BatchUploadResult, error)
BatchUpload batch upload files
func (*Client) CreateBucket ¶
func (c *Client) CreateBucket(req *CreateBucketRequest) error
CreateBucket 创建存储桶
func (*Client) DeleteBucket ¶
DeleteBucket 删除存储桶
func (*Client) GetBucketDomains ¶
GetBucketDomains 获取存储桶域名
func (*Client) GetFileInfo ¶
GetFileInfo 获取文件信息
func (*Client) GetFileURL ¶
GetFileURL 获取文件访问URL
func (*Client) ListBuckets ¶
ListBuckets 列举存储桶
func (*Client) ListFiles ¶
func (c *Client) ListFiles(req *ListFilesRequest) (*ListFilesResult, error)
ListFiles 列举文件
func (*Client) SetBucketPrivate ¶
func (c *Client) SetBucketPrivate(req *SetBucketPrivateRequest) error
SetBucketPrivate 设置存储桶权限
func (*Client) UploadBytes ¶
func (c *Client) UploadBytes(req *UploadBytesRequest) (*UploadResult, error)
UploadBytes upload file from bytes
func (*Client) UploadFile ¶
func (c *Client) UploadFile(req *UploadRequest) (*UploadResult, error)
UploadFile upload single files
func (*Client) UploadFromReader ¶
func (c *Client) UploadFromReader(req *UploadFromReaderRequest) (*UploadResult, error)
UploadFromReader upload from io.Reader
type Config ¶
type Config struct {
BaseURL string // LingStorage server address
APIKey string // API Key
APISecret string // API Secret
Timeout time.Duration // Request Timeout
RetryCount int // retry times
UserAgent string // user agent
}
Config LingStorage client config
type CopyFileRequest ¶
type CopyFileRequest struct {
SrcBucket string `json:"srcBucket"`
SrcKey string `json:"srcKey"`
DestBucket string `json:"destBucket"`
DestKey string `json:"destKey"`
}
CopyFileRequest 复制文件请求
type CreateBucketRequest ¶
type CreateBucketRequest struct {
BucketName string `json:"bucketName"`
Region string `json:"region"`
}
CreateBucketRequest 创建存储桶请求
type FileInfo ¶
type FileInfo struct {
Key string `json:"key"`
Size int64 `json:"size"`
LastModified time.Time `json:"lastModified"`
ETag string `json:"etag"`
ContentType string `json:"contentType"`
}
FileInfo 文件信息
type ListFilesRequest ¶
type ListFilesRequest struct {
Bucket string `json:"bucket"`
Prefix string `json:"prefix"`
Marker string `json:"marker"`
Delimiter string `json:"delimiter"`
Limit int `json:"limit"`
}
ListFilesRequest 列举文件请求
type ListFilesResult ¶
type ListFilesResult struct {
Files []FileInfo `json:"files"`
Directories []string `json:"directories"`
NextMarker string `json:"nextMarker"`
IsTruncated bool `json:"isTruncated"`
}
ListFilesResult 列举文件结果
type MoveFileRequest ¶
type MoveFileRequest struct {
SrcBucket string `json:"srcBucket"`
SrcKey string `json:"srcKey"`
DestBucket string `json:"destBucket"`
DestKey string `json:"destKey"`
}
MoveFileRequest 移动文件请求
type ProgressMonitor ¶
type ProgressMonitor struct {
// contains filtered or unexported fields
}
func NewProgressMonitor ¶
func NewProgressMonitor() *ProgressMonitor
func (*ProgressMonitor) GetTotalDuration ¶
func (pm *ProgressMonitor) GetTotalDuration() time.Duration
func (*ProgressMonitor) OnProgress ¶
func (pm *ProgressMonitor) OnProgress(uploaded, total int64)
type SetBucketPrivateRequest ¶
type SetBucketPrivateRequest struct {
BucketName string `json:"bucketName"`
IsPrivate bool `json:"isPrivate"`
}
SetBucketPrivateRequest 设置存储桶权限请求
type UploadBytesRequest ¶
type UploadBytesRequest struct {
Data []byte // file data
Filename string // file name
Bucket string // bucket name
Key string // file key
AllowedTypes []string // all types
Compress bool // if compress file
Quality int // quality 1-100 - default 100
Watermark bool // if watermark
WatermarkText string // watermark text
WatermarkPosition string // watermark position
OnProgress func(uploaded, total int64) // upload progress callback
}
UploadBytesRequest upload request from bytes
type UploadError ¶
UploadError upload error
type UploadFromReaderRequest ¶
type UploadFromReaderRequest struct {
Reader io.Reader
Filename string
Size int64
Bucket string
Key string
AllowedTypes []string
Compress bool
Quality int
Watermark bool
WatermarkText string
WatermarkPosition string
OnProgress func(uploaded, total int64)
}
UploadFromReaderRequest read from io.Reader
type UploadRequest ¶
type UploadRequest struct {
FilePath string // file path
Bucket string // bucket name
Key string // file key name
AllowedTypes []string // all file types
Compress bool // if compress file
Quality int // quality 1-100 - default 100
Watermark bool // if watermark
WatermarkText string // watermark text
WatermarkPosition string // watermark position
OnProgress func(uploaded, total int64) // upload progress callback
}
UploadRequest upload request
type UploadResult ¶
type UploadResult struct {
Key string `json:"key"`
Bucket string `json:"bucket"`
Filename string `json:"filename"`
Size int64 `json:"size"`
OriginalSize int64 `json:"originalSize"`
Compressed bool `json:"compressed"`
Watermarked bool `json:"watermarked"`
URL string `json:"url"`
}
UploadResult upload result
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
basic_upload
command
|
|
|
file_management
command
|
|
|
progress_monitor
command
|