media

package
v0.0.0-...-0447b3e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2016 License: GPL-3.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

管理多媒体文件.

Index

Constants

View Source
const (
	MediaTypeImage = "image"
	MediaTypeVoice = "voice"
	MediaTypeVideo = "video"
	MediaTypeFile  = "file"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	corp.CorpClient
}

func NewClient

func NewClient(TokenServer corp.TokenServer, HttpClient *http.Client) *Client

创建一个新的 Client.

如果 HttpClient == nil 则默认用 http.DefaultClient

func (*Client) DownloadMedia

func (clt *Client) DownloadMedia(mediaId, filepath string) (err error)

下载多媒体到文件.

func (*Client) DownloadMediaToWriter

func (clt *Client) DownloadMediaToWriter(mediaId string, writer io.Writer) error

下载多媒体到 io.Writer.

func (*Client) UploadFile

func (clt *Client) UploadFile(filepath string) (info *MediaInfo, err error)

上传普通文件

func (*Client) UploadFileFromReader

func (clt *Client) UploadFileFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传普通文件

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

func (*Client) UploadImage

func (clt *Client) UploadImage(filepath string) (info *MediaInfo, err error)

上传多媒体图片

func (*Client) UploadImageFromReader

func (clt *Client) UploadImageFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传多媒体图片

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

func (*Client) UploadVideo

func (clt *Client) UploadVideo(filepath string) (info *MediaInfo, err error)

上传多媒体视频

func (*Client) UploadVideoFromReader

func (clt *Client) UploadVideoFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传多媒体视频

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

func (*Client) UploadVoice

func (clt *Client) UploadVoice(filepath string) (info *MediaInfo, err error)

上传多媒体语音

func (*Client) UploadVoiceFromReader

func (clt *Client) UploadVoiceFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传多媒体语音

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

type MediaInfo

type MediaInfo struct {
	MediaType string `json:"type"`       // 媒体文件类型,分别有图片(image)、语音(voice)、视频(video),普通文件(file)
	MediaId   string `json:"media_id"`   // 媒体文件上传后获取的唯一标识
	CreatedAt int64  `json:"created_at"` // 媒体文件上传时间戳
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL