Skip to content

Commit

Permalink
fix: parent_id query param was missing
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Jul 9, 2024
1 parent 89c08f0 commit d9a78b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
22 changes: 11 additions & 11 deletions api/router/file_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,9 @@ func (r *FileRouter) DownloadThumbnail(c *fiber.Ctx) error {
// @Param workspace_id query string true "Workspace ID"
// @Param parent_id query string false "Parent ID"
// @Param name query string false "Name"
// @Param s3_key query string true "S3 Key"
// @Param s3_bucket query string true "S3 Bucket"
// @Param size query string true "Size"
// @Param s3_key query string true "S3 Key"
// @Param s3_bucket query string true "S3 Bucket"
// @Param size query string true "Size"
// @Success 200 {object} service.File
// @Failure 404 {object} errorpkg.ErrorResponse
// @Failure 400 {object} errorpkg.ErrorResponse
Expand Down Expand Up @@ -1036,14 +1036,14 @@ func (r *FileRouter) CreateFromS3(c *fiber.Ctx) error {
// @Produce json
// @Param api_key query string true "API Key"
// @Param access_token query string true "Access Token"
// @Param s3_key query string true "S3 Key"
// @Param s3_bucket query string true "S3 Bucket"
// @Param size query string true "Size"
// @Param id path string true "ID"
// @Success 200 {object} service.File
// @Failure 404 {object} errorpkg.ErrorResponse
// @Failure 400 {object} errorpkg.ErrorResponse
// @Failure 500 {object} errorpkg.ErrorResponse
// @Param s3_key query string true "S3 Key"
// @Param s3_bucket query string true "S3 Bucket"
// @Param size query string true "Size"
// @Param id path string true "ID"
// @Success 200 {object} service.File
// @Failure 404 {object} errorpkg.ErrorResponse
// @Failure 400 {object} errorpkg.ErrorResponse
// @Failure 500 {object} errorpkg.ErrorResponse
// @Router /files/{id}/patch_from_s3 [patch]
func (r *FileRouter) PatchFromS3(c *fiber.Ctx) error {
apiKey := c.Query("api_key")
Expand Down
18 changes: 15 additions & 3 deletions webdav-go/client/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ func (cl *APIClient) CreateFileFromS3(opts FileCreateFromS3Options) (*File, erro
return nil, err
}
req, err := http.NewRequest("POST",
fmt.Sprintf("%s/v2/files/create_from_s3?api_key=%s&access_token=%s&workspace_id=%s&name=%s&s3_key=%s&s3_bucket=%s&snapshot_id=%s&content_type=%s&size=%d",
fmt.Sprintf("%s/v2/files/create_from_s3?api_key=%s&access_token=%s&workspace_id=%s&parent_id=%s&name=%s&s3_key=%s&s3_bucket=%s&snapshot_id=%s&content_type=%s&size=%d",
cl.config.APIURL,
cl.config.Security.APIKey,
cl.token.AccessToken,
opts.WorkspaceID,
opts.ParentID,
opts.Name,
opts.S3Reference.Key,
opts.S3Reference.Bucket,
Expand All @@ -157,7 +158,13 @@ func (cl *APIClient) CreateFileFromS3(opts FileCreateFromS3Options) (*File, erro
if err != nil {
return nil, err
}
defer res.Body.Close()
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
infra.GetLogger().Error(err.Error())
return
}
}(res.Body)
var file File
if err = json.Unmarshal(body, &file); err != nil {
return nil, err
Expand Down Expand Up @@ -199,7 +206,12 @@ func (cl *APIClient) PatchFileFromS3(opts FilePatchFromS3Options) (*File, error)
if err != nil {
return nil, err
}
defer res.Body.Close()
defer func(Body io.ReadCloser) {
if err := Body.Close(); err != nil {
infra.GetLogger().Error(err.Error())
return
}
}(res.Body)
var file File
if err = json.Unmarshal(body, &file); err != nil {
return nil, err
Expand Down

0 comments on commit d9a78b6

Please sign in to comment.