diff options
Diffstat (limited to 'go/operation')
| -rw-r--r-- | go/operation/allocate_volume.go | 6 | ||||
| -rw-r--r-- | go/operation/lookup_volume_id.go | 4 | ||||
| -rw-r--r-- | go/operation/upload_content.go | 14 |
3 files changed, 17 insertions, 7 deletions
diff --git a/go/operation/allocate_volume.go b/go/operation/allocate_volume.go index 19166eaed..ea34901ef 100644 --- a/go/operation/allocate_volume.go +++ b/go/operation/allocate_volume.go @@ -1,12 +1,12 @@ package operation import ( - "encoding/json" - "errors" - "net/url" "code.google.com/p/weed-fs/go/storage" "code.google.com/p/weed-fs/go/topology" "code.google.com/p/weed-fs/go/util" + "encoding/json" + "errors" + "net/url" ) type AllocateVolumeResult struct { diff --git a/go/operation/lookup_volume_id.go b/go/operation/lookup_volume_id.go index 8512ac918..0d8f247be 100644 --- a/go/operation/lookup_volume_id.go +++ b/go/operation/lookup_volume_id.go @@ -1,12 +1,12 @@ package operation import ( + "code.google.com/p/weed-fs/go/storage" + "code.google.com/p/weed-fs/go/util" "encoding/json" "errors" _ "fmt" "net/url" - "code.google.com/p/weed-fs/go/storage" - "code.google.com/p/weed-fs/go/util" ) type Location struct { diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go index 0bdb697da..cae657b2c 100644 --- a/go/operation/upload_content.go +++ b/go/operation/upload_content.go @@ -21,9 +21,19 @@ func Upload(uploadUrl string, filename string, reader io.Reader) (*UploadResult, body_buf := bytes.NewBufferString("") body_writer := multipart.NewWriter(body_buf) file_writer, err := body_writer.CreateFormFile("file", filename) - io.Copy(file_writer, reader) + if err != nil { + log.Println("error creating form file", err) + return nil, err + } + if _, err = io.Copy(file_writer, reader); err != nil { + log.Println("error copying data", err) + return nil, err + } content_type := body_writer.FormDataContentType() - body_writer.Close() + if err = body_writer.Close(); err != nil { + log.Println("error closing body", err) + return nil, err + } resp, err := http.Post(uploadUrl, content_type, body_buf) if err != nil { log.Println("failing to upload to", uploadUrl) |
