From 8054552054de5a98e16cd477d64545df3a5328bf Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Mon, 20 Nov 2023 17:15:54 -0500 Subject: [PATCH] =?UTF-8?q?fix!:=20d=C3=A9placer=20V1DocumentPOST.Data.Buc?= =?UTF-8?q?ket=20=C3=A0=20Params?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING: renommer champs Data.Bucket à Params.Bucket pour V1DocumentPOST --- apihandler/document.go | 6 +++--- apirequest/document.go | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apihandler/document.go b/apihandler/document.go index 29b70b5..844a114 100644 --- a/apihandler/document.go +++ b/apihandler/document.go @@ -15,7 +15,7 @@ func (h *V1Handler) V1DocumentPOST(c echo.Context) (err error) { var request apirequest.V1DocumentPOST var response apiresponse.V1DocumentPOST - request.Data.Bucket = c.Param("bucket") + request.Params.Bucket = c.Param("bucket") request.Data.Document, err = c.FormFile("document") if err != nil { @@ -28,7 +28,7 @@ func (h *V1Handler) V1DocumentPOST(c echo.Context) (err error) { allowed := false for bucket_allowed := range h.Config.Server.Documents.Buckets { - if request.Data.Bucket == bucket_allowed { + if request.Params.Bucket == bucket_allowed { allowed = true } } @@ -58,7 +58,7 @@ func (h *V1Handler) V1DocumentPOST(c echo.Context) (err error) { } defer src.Close() - info, err := h.MediaClient.MinioClient.PutObject(ctx, request.Data.Bucket, request.Data.Document.Filename, src, request.Data.Document.Size, minio.PutObjectOptions{ + info, err := h.MediaClient.MinioClient.PutObject(ctx, request.Params.Bucket, request.Data.Document.Filename, src, request.Data.Document.Size, minio.PutObjectOptions{ ContentType: request.Data.Document.Header.Get("Content-Type"), }) if err != nil { diff --git a/apirequest/document.go b/apirequest/document.go index c5c1f9a..2cdb218 100644 --- a/apirequest/document.go +++ b/apirequest/document.go @@ -16,9 +16,11 @@ var _ request.Requester[apiresponse.V1DocumentPOST] = V1DocumentPOST{} type V1DocumentPOST struct { Data struct { - Bucket string Document *multipart.FileHeader } + Params struct { + Bucket string + } } func NewV1DocumentPOST(bucket string, document *multipart.FileHeader) (request V1DocumentPOST, err error) { @@ -27,7 +29,7 @@ func NewV1DocumentPOST(bucket string, document *multipart.FileHeader) (request V return } - request.Data.Bucket = bucket + request.Params.Bucket = bucket if document == nil { err = fmt.Errorf("NewV1DocumentPOST requires non-nil document") @@ -40,7 +42,7 @@ func NewV1DocumentPOST(bucket string, document *multipart.FileHeader) (request V } func (request V1DocumentPOST) Complete() bool { - return request.Data.Bucket != "" && request.Data.Document != nil + return request.Params.Bucket != "" && request.Data.Document != nil } func (request V1DocumentPOST) Request(v *voki.Voki) (response apiresponse.V1DocumentPOST, err error) { @@ -54,7 +56,7 @@ func (request V1DocumentPOST) Request(v *voki.Voki) (response apiresponse.V1Docu return } - return response, v.UnmarshalIfComplete(http.MethodPost, fmt.Sprintf("/v1/bucket/%s", request.Data.Bucket), &buf, true, &response) + return response, v.UnmarshalIfComplete(http.MethodPost, fmt.Sprintf("/v1/bucket/%s", request.Params.Bucket), &buf, true, &response) } var _ request.Requester[apiresponse.V1DocumentDELETE] = V1DocumentDELETE{} -- 2.45.2