diff options
author | r <r@freesoftwareextremist.com> | 2019-12-14 20:19:02 +0000 |
---|---|---|
committer | r <r@freesoftwareextremist.com> | 2019-12-14 20:19:02 +0000 |
commit | e129ea922e6cbe8966f9a9f0b1c6c94401516c61 (patch) | |
tree | 35be3bc003b787db5898ac1ba8aacca3f944105e /mastodon/status.go | |
parent | ea66bd539dec12ef2846c23e505593f9f9d9fac3 (diff) | |
download | bloat-e129ea922e6cbe8966f9a9f0b1c6c94401516c61.tar.gz bloat-e129ea922e6cbe8966f9a9f0b1c6c94401516c61.zip |
Add attachments support
Diffstat (limited to 'mastodon/status.go')
-rw-r--r-- | mastodon/status.go | 11 |
1 files changed, 11 insertions, 0 deletions
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 +} |