diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-12-18 19:02:48 -0500 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-12-18 19:02:48 -0500 |
commit | cfdc5ab9998a86a8b540d8f5d5a7b429e919e4d6 (patch) | |
tree | 0f00aafc688e4216cc6c463313afcfe389ec628c /model/file_info.go | |
parent | 6288a1347e9870a5df8b3fee46066775d73367e5 (diff) | |
download | chat-cfdc5ab9998a86a8b540d8f5d5a7b429e919e4d6.tar.gz chat-cfdc5ab9998a86a8b540d8f5d5a7b429e919e4d6.tar.bz2 chat-cfdc5ab9998a86a8b540d8f5d5a7b429e919e4d6.zip |
Fixed TestGetFile unit test
Diffstat (limited to 'model/file_info.go')
-rw-r--r-- | model/file_info.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/model/file_info.go b/model/file_info.go index d96723f32..741b4e55d 100644 --- a/model/file_info.go +++ b/model/file_info.go @@ -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 + } +} |