Fix implémentations de UploadDocument et models.NotFoundResponse()
This commit is contained in:
parent
37eb18cfa5
commit
48a8c8a37a
4 changed files with 17 additions and 16 deletions
|
@ -127,7 +127,7 @@ func HandleV1BucketRead(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !allowed {
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -153,7 +153,7 @@ func HandleV1BucketRead(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !exists {
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
objectCh := mediaClient.MinioClient.ListObjects(ctx, bucket, minio.ListObjectsOptions{})
|
||||
|
@ -208,7 +208,7 @@ func HandleV1DocumentCreate(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !allowed {
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -255,6 +255,7 @@ func HandleV1DocumentCreate(c echo.Context) error {
|
|||
}
|
||||
|
||||
response.StatusCode = http.StatusOK
|
||||
response.Message = "ok"
|
||||
response.Data.Bucket = info.Bucket
|
||||
response.Data.Key = info.Key
|
||||
response.Data.Size = info.Size
|
||||
|
@ -282,7 +283,7 @@ func HandleV1DocumentRead(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !allowed {
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -303,7 +304,7 @@ func HandleV1DocumentRead(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !bucket_exists {
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
document_info, err := mediaClient.MinioClient.StatObject(ctx, bucket, document, minio.StatObjectOptions{})
|
||||
|
@ -311,7 +312,7 @@ func HandleV1DocumentRead(c echo.Context) error {
|
|||
if err != nil {
|
||||
if err.Error() == "The specified key does not exist." {
|
||||
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusInternalServerError, map[string]interface{}{
|
||||
|
@ -357,7 +358,7 @@ func HandleV1DocumentDelete(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !allowed {
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
@ -378,14 +379,14 @@ func HandleV1DocumentDelete(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !bucket_exists {
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
document_info, err := mediaClient.MinioClient.StatObject(ctx, bucket, document, minio.StatObjectOptions{})
|
||||
if err != nil {
|
||||
if err.Error() == "The specified key does not exist." {
|
||||
|
||||
return c.JSON(http.StatusNotFound, models.NotFoundResponse())
|
||||
return c.JSON(models.NotFoundResponse())
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusInternalServerError, map[string]interface{}{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue