Этот коммит содержится в:
hmhealey
2015-12-18 19:02:48 -05:00
родитель 6288a1347e
Коммит cfdc5ab999
3 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@@ -152,7 +152,6 @@ func TestGetFile(t *testing.T) {
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
if utils.Cfg.FileSettings.DriverName != "" {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile("files", "test.png")
@@ -204,9 +203,9 @@ func TestGetFile(t *testing.T) {
if resp, downErr := Client.GetFileInfo(filenames[0]); downErr != nil {
t.Fatal(downErr)
} else {
m := resp.Data.(map[string]string)
if len(m["size"]) == 0 {
t.Fail()
info := resp.Data.(*model.FileInfo)
if info.Size == 0 {
t.Fatal("No file size returned")
}
}

Просмотреть файл

@@ -717,7 +717,7 @@ func (c *Client) GetFileInfo(url string) (*Result, *AppError) {
return nil, AppErrorFromJson(rp.Body)
} else {
return &Result{rp.Header.Get(HEADER_REQUEST_ID),
rp.Header.Get(HEADER_ETAG_SERVER), MapFromJson(rp.Body)}, nil
rp.Header.Get(HEADER_ETAG_SERVER), FileInfoFromJson(rp.Body)}, nil
}
}

Просмотреть файл

@@ -7,6 +7,7 @@ import (
"bytes"
"encoding/json"
"image/gif"
"io"
"mime"
"path/filepath"
)
@@ -58,3 +59,14 @@ func (info *FileInfo) ToJson() string {
return string(b)
}
}
func FileInfoFromJson(data io.Reader) *FileInfo {
decoder := json.NewDecoder(data)
var info FileInfo
if err := decoder.Decode(&info); err != nil {
return nil
} else {
return &info
}
}