aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Wang2023-05-12 21:26:25 -0400
committerDaniel Wang2023-05-12 21:26:25 -0400
commitf1a03b2082de8ed16c80ae5e030eda9c87c5e702 (patch)
tree8fca134ae380d5e8383cfbfefd0ff60d21cf85c2
parentae29c8b047e16eb8357fd30f1cd970d124a71ec1 (diff)
Added client
-rw-r--r--client/main.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/client/main.go b/client/main.go
index 5397384..47af004 100644
--- a/client/main.go
+++ b/client/main.go
@@ -6,6 +6,7 @@ import (
"encoding/base64"
"flag"
"fmt"
+ "io"
"net/http"
"os"
"strings"
@@ -116,5 +117,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,
+ )
}
}