Skip to content

Commit 33b779f

Browse files
author
Josh Cave
committed
helper tidy
1 parent 641ff2e commit 33b779f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fileupload.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func NewImageHelper(endpoint string, fs FileSaver) *imageProcessHelper {
273273
}
274274
}
275275

276-
func (ip *imageProcessHelper) GetDimensions(bts []byte, ext string) (width int, height int, err error) {
276+
func (ip *imageProcessHelper) GetDimensions(bts io.Reader, ext string) (width int, height int, err error) {
277277
ext = strings.ToLower(ext)
278278
var imgConfig image.Config
279279
if strings.HasSuffix(ext, "jpeg") || strings.HasSuffix(ext, "jpg") {
@@ -287,7 +287,7 @@ func (ip *imageProcessHelper) GetDimensions(bts []byte, ext string) (width int,
287287
return imgConfig.Width, imgConfig.Width, nil
288288
}
289289

290-
func (ip *imageProcessHelper) ProcessImage(filename string, bts []byte, ops *operations) (byts *bytes.Buffer, fileName string, url string, err error) {
290+
func (ip *imageProcessHelper) ProcessImage(filename string, imgData io.Reader, ops *operations) (byts *bytes.Buffer, fileName string, url string, err error) {
291291
ext := filepath.Ext(filename)
292292

293293
bOps, err := json.Marshal(ops.Ops)
@@ -302,7 +302,7 @@ func (ip *imageProcessHelper) ProcessImage(filename string, bts []byte, ops *ope
302302
return nil, "", "", fmt.Errorf("mpW.CreateFormFile %v", err)
303303
// ctx.ErrorJSON(http.StatusOK, "couldn't create form file ", err)
304304
}
305-
_, err = io.Copy(fw, bytes.NewBuffer(bts))
305+
_, err = io.Copy(fw, imgData)
306306
if err != nil {
307307
// ctx.ErrorJSON(http.StatusOK, "failed to copy from reqFile", err)
308308
return nil, "", "", fmt.Errorf("failed to copy to multipart writer %v", err)

0 commit comments

Comments
 (0)