diff --git a/internal/httpserver/httpServer.go b/internal/httpserver/httpServer.go index 2cebd68..887c6ab 100644 --- a/internal/httpserver/httpServer.go +++ b/internal/httpserver/httpServer.go @@ -112,12 +112,21 @@ func httpGetFile(ctx context.Context, rw http.ResponseWriter, r *http.Request) { } s3Client := ctx.Value("s3Client").(*minio.Client) - id := r.URL.Query().Get("id") + idString := r.URL.Query().Get("id") + + id := types.ParseID(idString) + + if id == nil { + // Failed to parse ID + rw.WriteHeader(http.StatusBadRequest) + return + } log.Debug("S3 call 'StatObject': ", id) - objInfo, err := s3Client.StatObject(context.Background(), "dev", id, minio.GetObjectOptions{}) + objInfo, err := s3Client.StatObject(context.Background(), id.Bucket, id.Key, minio.GetObjectOptions{}) if err != nil { + log.Error("Failed to get object info: ", err) rw.WriteHeader(http.StatusInternalServerError) return } @@ -129,9 +138,10 @@ func httpGetFile(ctx context.Context, rw http.ResponseWriter, r *http.Request) { } log.Debug("S3 call 'GetObject': ", id) - obj, err := s3Client.GetObject(context.Background(), "dev", id, minio.GetObjectOptions{}) + obj, err := s3Client.GetObject(context.Background(), id.Bucket, id.Key, minio.GetObjectOptions{}) if err != nil { + log.Error("Failed to get object: ", err) rw.WriteHeader(http.StatusInternalServerError) return }