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 bug with bucket name extraction

+4 -3
+4 -3
server.go
··· 8 8 "net/http" 9 9 "os" 10 10 "path/filepath" 11 + "strings" 11 12 ) 12 13 13 14 type server struct { ··· 52 53 53 54 path := filepath.Join(r.PathValue("bucket"), r.PathValue("key")) 54 55 55 - bucketName := filepath.SplitList(path)[0] 56 + bucketName := strings.Split(path, "/")[0] 56 57 if err := root.Mkdir(bucketName, 0775); err != nil { 57 58 if errors.Is(err, fs.ErrExist) { 58 59 http.Error(w, "Your previous request to create the named bucket succeeded and you already own it.", http.StatusConflict) ··· 74 75 75 76 path := filepath.Join(r.PathValue("bucket"), r.PathValue("key")) 76 77 77 - bucketName := filepath.SplitList(path)[0] 78 + bucketName := strings.Split(path, "/")[0] 78 79 files, err := fs.ReadDir(root.FS(), bucketName) 79 80 if err != nil { 80 81 if errors.Is(err, fs.ErrNotExist) { ··· 107 108 path := filepath.Join(r.PathValue("bucket"), r.PathValue("key")) 108 109 109 110 // Prevents `cp` from accidentally creating a new bucket if it doesn't exist 110 - bucketName := filepath.SplitList(path)[0] 111 + bucketName := strings.Split(path, "/")[0] 111 112 if _, err := root.Stat(bucketName); err != nil { 112 113 if errors.Is(err, fs.ErrNotExist) { 113 114 http.Error(w, "The specified bucket does not exist", http.StatusNotFound)