Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
ciao-cli: For image uploads don't read whole image into memory
Browse files Browse the repository at this point in the history
Remove the intermediate code that reads the whole image file into
memory.

Fixes: #662

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
  • Loading branch information
rbradford committed Nov 22, 2016
1 parent cc089c2 commit c4de6ed
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions ciao-cli/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package main

import (
"bytes"
"errors"
"flag"
"fmt"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit c4de6ed

Please sign in to comment.