add UploadMedia

This commit is contained in:
Yasuhiro Matsumoto 2017-04-17 13:54:36 +09:00
parent 959459eb42
commit af67397430
3 changed files with 82 additions and 5 deletions

View file

@ -201,3 +201,13 @@ func (c *Client) Search(ctx context.Context, q string, resolve bool) (*Results,
}
return &results, nil
}
// PostMedia upload a media attachment.
func (c *Client) UploadMedia(ctx context.Context, file string) (*Attachment, error) {
var attachment Attachment
err := c.doAPI(ctx, http.MethodPost, "/api/v1/media", file, &attachment)
if err != nil {
return nil, err
}
return &attachment, nil
}