Simple S3-like server for development purposes, written in Go
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix accidental bucket creation

+10
+10
gos3dir.go
··· 76 76 bucketName := r.PathValue("bucket") 77 77 key := r.PathValue("key") 78 78 79 + // Prevents `cp` from accidentally creating a new bucket if it doesn't exist 80 + if _, err := os.Stat(bucketName); err != nil { 81 + if errors.Is(err, fs.ErrNotExist) { 82 + http.Error(w, "The specified bucket does not exist", http.StatusNotFound) 83 + } else { 84 + http.Error(w, err.Error(), http.StatusInternalServerError) 85 + } 86 + return 87 + } 88 + 79 89 path := filepath.Join(bucketName, key) 80 90 if err := os.MkdirAll(filepath.Dir(path), 0775); err != nil { 81 91 http.Error(w, err.Error(), http.StatusInternalServerError)