diff --git a/clients/go/.gitignore b/clients/go/.gitignore new file mode 100644 index 000000000..9a3dc9110 --- /dev/null +++ b/clients/go/.gitignore @@ -0,0 +1,4 @@ +*.8 +*.6 +camliup + diff --git a/clients/go/camliup.go b/clients/go/camliup.go index 52abaee04..e82a8d417 100644 --- a/clients/go/camliup.go +++ b/clients/go/camliup.go @@ -17,7 +17,8 @@ import ( ) var flagFile *string = flag.String("file", "", "file to upload") -var flagServer *string = flag.String("server", "http://localhost:3179/", "camlistore server") +var flagServer *string = flag.String("server", "http://localhost:3179/", "camlistore blob server") +var flagPassword *string = flag.String("password", "", "password for blob server") type UploadHandle struct { blobref string @@ -120,7 +121,7 @@ func blobName(contents io.ReadSeeker) string { return fmt.Sprintf("sha1-%x", s1.Sum()) } -func uploadFile(agent *Agent, filename string) os.Error { +func (a *Agent) UploadFileName(filename string) os.Error { file, err := os.Open(filename, os.O_RDONLY, 0) if err != nil { return err @@ -128,7 +129,7 @@ func uploadFile(agent *Agent, filename string) os.Error { fmt.Println("blob is:", blobName(file)) handle := &UploadHandle{blobName(file), file} - agent.Upload(handle) + a.Upload(handle) return nil } @@ -140,11 +141,15 @@ func main() { *flagServer = (*flagServer)[0 : len(*flagServer)-1] } - agent := NewAgent(*flagServer) - if *flagFile != "" { - uploadFile(agent, *flagFile) + if *flagFile == "" { + fmt.Println("Usage: camliup -file=[filename]") + flag.PrintDefaults() + return } + agent := NewAgent(*flagServer) + agent.UploadFileName(*flagFile) + stats := agent.Wait() fmt.Println("Done uploading; stats:", stats) }