This commit is contained in:
Mikaël Cluseau 2020-10-02 06:40:57 +02:00
parent 6727636e77
commit 541e74c7df
2 changed files with 6 additions and 0 deletions

View File

@ -62,6 +62,7 @@ func main() {
req, err := http.NewRequest("POST", outURL, in)
fail(err)
req.Header.Set("Authorization", "Bearer "+*token)
req.Header.Set("X-Content-SHA1", sha1Hex)
log.Print("uploading...")

View File

@ -58,6 +58,11 @@ func handleHTTP(w http.ResponseWriter, req *http.Request) {
http.ServeFile(w, req, filePath)
case "POST":
if req.Header.Get("Authorization") != ("Bearer " + *uploadToken) {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
tmpOut := filepath.Join(filepath.Dir(filePath), "."+filepath.Base(filePath))
if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil {