Documentation ¶
Index ¶
- type Client
- func (c *Client) Delete(remotes ...string) error
- func (c *Client) DeleteWithContext(ctx context.Context, remotes ...string) error
- func (c *Client) Download(remote string, respBody io.Writer) (*Request, error)
- func (c *Client) DownloadAsync(remote string, respBody io.Writer) (*Request, error)
- func (c *Client) DownloadAsyncWithContext(ctx context.Context, remote string, respBody io.Writer) (*Request, error)
- func (c *Client) DownloadWithContext(ctx context.Context, remote string, respBody io.Writer) (*Request, error)
- func (c *Client) Exists(remote string) (bool, *Request, error)
- func (c *Client) ExistsWithContext(ctx context.Context, remote string) (exists bool, req *Request, err error)
- func (c *Client) ImageInfo(remote string) (*ImageInfo, *Request, error)
- func (c *Client) ImageInfoWithContext(ctx context.Context, remote string) (info *ImageInfo, req *Request, err error)
- func (c *Client) List(prefix string, recursive bool) (ListResult, error)
- func (c *Client) ListWithContext(ctx context.Context, prefix string, recursive bool) (result ListResult, err error)
- func (c *Client) PostForm(key string, maxSize int64, duration time.Duration, ...) map[string]string
- func (c *Client) URL(remote string) string
- func (c *Client) Upload(remote string, reqBody io.Reader, reqBodyMd5 []byte, contentType string) (*Request, error)
- func (c *Client) UploadWithContext(ctx context.Context, remote string, reqBody io.Reader, reqBodyMd5 []byte, ...) (*Request, error)
- type Directory
- type File
- type ImageInfo
- type ListResult
- type Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
An OSS client must have prefix, bucket, access key ID and access key secret. Prefix should be a string like this: https://<your-bucket>.<region>.aliyuncs.com.
func (*Client) DeleteWithContext ¶ added in v1.1.0
Delete creates and executes a delete request for multiple remote keys (paths) at the same time.
func (*Client) DownloadAsync ¶
DownloadAsync wraps DownloadAsyncWithContext using context.Background.
func (*Client) DownloadAsyncWithContext ¶ added in v1.1.0
func (c *Client) DownloadAsyncWithContext(ctx context.Context, remote string, respBody io.Writer) (*Request, error)
DownloadAsync is like Download but won't wait till download is complete.
func (*Client) DownloadWithContext ¶ added in v1.1.0
func (c *Client) DownloadWithContext(ctx context.Context, remote string, respBody io.Writer) (*Request, error)
Download creates and executes a download request from remote path to respBody (io.Writer), returns the request and error. You can use bytes.Buffer to download the file to memory. If you want to have more than one destination, use io.MultiWriter.
func (*Client) ExistsWithContext ¶ added in v1.1.0
func (*Client) ImageInfoWithContext ¶ added in v1.3.0
func (*Client) List ¶
func (c *Client) List(prefix string, recursive bool) (ListResult, error)
List wraps ListWithContext using context.Background.
func (*Client) ListWithContext ¶ added in v1.1.0
func (c *Client) ListWithContext(ctx context.Context, prefix string, recursive bool) (result ListResult, err error)
List creates and executes a list request for remote files and directories under prefix, recursively if recursive is set to true.
func (*Client) PostForm ¶ added in v1.2.0
func (c *Client) PostForm(key string, maxSize int64, duration time.Duration, extraConditions ...interface{}) map[string]string
PostForm generates field names and values ("token") for multipart form. This is generally used when frontend user asks backend server for a token to upload a file to OSS. The "key" is the path to remote file. If "maxSize" is greater than 0, file larger than the "maxSize" bytes limit will not be uploaded. The token will be expired after "duration" time, default is 10 minutes. You can provide "extraConditions" like below to add limits to the uploaded file:
client.PostForm(key, 0, 0, []string{"starts-with", "$content-type", "application/"}, map[string]string{"x-oss-object-acl": "public-read"}, )
For more info, visit https://help.aliyun.com/document_detail/31988.html#title-5go-s2f-dnw
func (*Client) Upload ¶
func (c *Client) Upload(remote string, reqBody io.Reader, reqBodyMd5 []byte, contentType string) (*Request, error)
Upload wraps UploadWithContext using context.Background.
func (*Client) UploadWithContext ¶ added in v1.1.0
func (c *Client) UploadWithContext(ctx context.Context, remote string, reqBody io.Reader, reqBodyMd5 []byte, contentType string) (*Request, error)
Upload creates and executes a upload request for reqBody (io.Reader) to remote path, returns the request and error. reqBodyMd5 can be nil, OSS will run MD5 check if it is provided. If contentType is empty, "application/octet-stream" will be used. If the body is bytes, use bytes.NewReader. If it is a string, use strings.NewReader.