diff options
Diffstat (limited to 'app/file.go')
-rw-r--r-- | app/file.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/file.go b/app/file.go index 87e1986a2..cb8d54cb1 100644 --- a/app/file.go +++ b/app/file.go @@ -78,12 +78,13 @@ func (a *App) MoveFile(oldPath, newPath string) *model.AppError { return backend.MoveFile(oldPath, newPath) } -func (a *App) WriteFile(f []byte, path string) *model.AppError { +func (a *App) WriteFile(fr io.Reader, path string) (int64, *model.AppError) { backend, err := a.FileBackend() if err != nil { - return err + return 0, err } - return backend.WriteFile(f, path) + + return backend.WriteFile(fr, path) } func (a *App) RemoveFile(path string) *model.AppError { @@ -414,7 +415,7 @@ func (a *App) DoUploadFile(now time.Time, rawTeamId string, rawChannelId string, info.ThumbnailPath = pathPrefix + nameWithoutExtension + "_thumb.jpg" } - if err := a.WriteFile(data, info.Path); err != nil { + if _, err := a.WriteFile(bytes.NewReader(data), info.Path); err != nil { return nil, err } @@ -531,7 +532,7 @@ func (a *App) generateThumbnailImage(img image.Image, thumbnailPath string, widt return } - if err := a.WriteFile(buf.Bytes(), thumbnailPath); err != nil { + if _, err := a.WriteFile(buf, thumbnailPath); err != nil { mlog.Error(fmt.Sprintf("Unable to upload thumbnail path=%v err=%v", thumbnailPath, err)) return } @@ -553,7 +554,7 @@ func (a *App) generatePreviewImage(img image.Image, previewPath string, width in return } - if err := a.WriteFile(buf.Bytes(), previewPath); err != nil { + if _, err := a.WriteFile(buf, previewPath); err != nil { mlog.Error(fmt.Sprintf("Unable to upload preview err=%v", err), mlog.String("path", previewPath)) return } |