diff options
Diffstat (limited to 'client/main.go')
-rw-r--r-- | client/main.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/client/main.go b/client/main.go index 150e160..d490d56 100644 --- a/client/main.go +++ b/client/main.go @@ -7,6 +7,7 @@ import ( "encoding/binary" "flag" "fmt" + "io" "net/http" "os" "strings" @@ -135,5 +136,19 @@ func main() { if err != nil { panic(err) } + } else if flag.Arg(0) == "get" { + user := flag.Arg(1) + filename := flag.Arg(2) + response, _ := http.Get(servers[0] + "/storage/" + user + "/" + filename) + responseBodyBytes, _ := io.ReadAll(response.Body) + os.WriteFile(user + "/" + filename, responseBodyBytes, 0644) + } else if flag.Arg(0) == "post" { + filename := flag.Arg(1) + file, _ := os.Open(filename) + http.Post( + servers[0] + "/storage/" + id + "/" + filename, + "application/octet-stream", + file, + ) } } |