From c4de6edc200bbbed1255bc345856c8fe24d1b9bb Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 22 Nov 2016 19:18:11 +0000 Subject: [PATCH] ciao-cli: For image uploads don't read whole image into memory Remove the intermediate code that reads the whole image file into memory. Fixes: #662 Signed-off-by: Rob Bradford --- ciao-cli/image.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ciao-cli/image.go b/ciao-cli/image.go index 51c4cea1b..4f4487406 100644 --- a/ciao-cli/image.go +++ b/ciao-cli/image.go @@ -17,7 +17,6 @@ package main import ( - "bytes" "errors" "flag" "fmt" @@ -428,14 +427,7 @@ func uploadTenantImage(username, password, tenant, image, filename string) error } defer file.Close() - fileInfo, _ := file.Stat() - var size = fileInfo.Size() - buffer := make([]byte, size) - - file.Read(buffer) - fileBytes := bytes.NewReader(buffer) - - res := images.Upload(client, image, fileBytes) + res := images.Upload(client, image, file) if res.Err != nil { fatalf("Could not upload %s [%s]", filename, res.Err) }