diff options
author | Corey Hulen <corey@hulen.com> | 2015-08-25 13:17:21 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-08-25 13:17:21 -0700 |
commit | eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac (patch) | |
tree | 8407caf850b9246b30d7ce2ca6726e66244b7ce2 /model/client.go | |
parent | b4ee26373042d2c5ab422a4955022fb278cb8fa1 (diff) | |
parent | 64b179ab0e6a66c0f8edb72ab24ef28bbc2f9969 (diff) | |
download | chat-eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac.tar.gz chat-eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac.tar.bz2 chat-eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac.zip |
Merge pull request #466 from mattermost/mm-1912
Fixes mm-1912 move get file info into its own web service call
Diffstat (limited to 'model/client.go')
-rw-r--r-- | model/client.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/model/client.go b/model/client.go index 17e2466df..9fcb06cf8 100644 --- a/model/client.go +++ b/model/client.go @@ -589,6 +589,24 @@ func (c *Client) GetFile(url string, isFullUrl bool) (*Result, *AppError) { } } +func (c *Client) GetFileInfo(url string) (*Result, *AppError) { + var rq *http.Request + rq, _ = http.NewRequest("GET", c.Url+"/files/get_info"+url, nil) + + if len(c.AuthToken) > 0 { + rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken) + } + + if rp, err := c.HttpClient.Do(rq); err != nil { + return nil, NewAppError(url, "We encountered an error while connecting to the server", err.Error()) + } else if rp.StatusCode >= 300 { + return nil, AppErrorFromJson(rp.Body) + } else { + return &Result{rp.Header.Get(HEADER_REQUEST_ID), + rp.Header.Get(HEADER_ETAG_SERVER), MapFromJson(rp.Body)}, nil + } +} + func (c *Client) GetPublicLink(data map[string]string) (*Result, *AppError) { if r, err := c.DoPost("/files/get_public_link", MapToJson(data)); err != nil { return nil, err |