media

package
v0.0.0-...-7011273 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: 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(AccessTokenServer corp.AccessTokenServer, httpClient *http.Client) Client

兼容保留, 建議實際項目全局維護一個 *corp.CorpClient

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