mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-14 15:54:53 +08:00
add lots of error checking by GThomas
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user