From e129ea922e6cbe8966f9a9f0b1c6c94401516c61 Mon Sep 17 00:00:00 2001 From: r Date: Sat, 14 Dec 2019 20:19:02 +0000 Subject: Add attachments support --- mastodon/status.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'mastodon/status.go') diff --git a/mastodon/status.go b/mastodon/status.go index fd69914..b6110d5 100644 --- a/mastodon/status.go +++ b/mastodon/status.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "io" + "mime/multipart" "net/http" "net/url" "time" @@ -295,3 +296,13 @@ func (c *Client) UploadMediaFromReader(ctx context.Context, reader io.Reader) (* } return &attachment, nil } + +// UploadMediaFromReader uploads a media attachment from a io.Reader. +func (c *Client) UploadMediaFromMultipartFileHeader(ctx context.Context, fh *multipart.FileHeader) (*Attachment, error) { + var attachment Attachment + err := c.doAPI(ctx, http.MethodPost, "/api/v1/media", fh, &attachment, nil) + if err != nil { + return nil, err + } + return &attachment, nil +} -- cgit v1.2.3