Skip to content

Commit

Permalink
Merge pull request #113 from humio/mike/files_list_searchdomain
Browse files Browse the repository at this point in the history
Fix file list/download/upload
  • Loading branch information
SaaldjorMike authored Sep 14, 2022
2 parents 6de5c77 + c952a99 commit d887c11
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ func (c *Client) Files() *Files { return &Files{client: c} }

func (f *Files) List(viewName string) ([]File, error) {
var query struct {
Repository struct {
SearchDomain struct {
Files []File
} `graphql:"repository(name:$viewName)"`
} `graphql:"searchDomain(name:$viewName)"`
}

variables := map[string]interface{}{
"viewName": graphql.String(viewName),
}

err := f.client.Query(&query, variables)
return query.Repository.Files, err
return query.SearchDomain.Files, err
}

func (f *Files) Delete(viewName string, fileName string) error {
Expand Down Expand Up @@ -66,7 +66,7 @@ func (f *Files) Upload(viewName string, fileName string, reader io.Reader) error

eg.Go(func() error {
var err error
resp, err = f.client.HTTPRequestContext(ctx, http.MethodPost, fmt.Sprintf("api/v1/dataspaces/%s/files", url.QueryEscape(viewName)), pr, multipartWriter.FormDataContentType())
resp, err = f.client.HTTPRequestContext(ctx, http.MethodPost, fmt.Sprintf("api/v1/dataspaces/%s/files", url.PathEscape(viewName)), pr, multipartWriter.FormDataContentType())
return err
})

Expand Down Expand Up @@ -99,7 +99,7 @@ func (f *Files) Upload(viewName string, fileName string, reader io.Reader) error
}

func (f *Files) Download(viewName string, fileName string) (io.Reader, error) {
resp, err := f.client.HTTPRequest(http.MethodGet, fmt.Sprintf("api/v1/dataspaces/%s/files/%s", url.QueryEscape(viewName), url.QueryEscape(fileName)), nil)
resp, err := f.client.HTTPRequest(http.MethodGet, fmt.Sprintf("api/v1/dataspaces/%s/files/%s", url.PathEscape(viewName), url.PathEscape(fileName)), nil)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d887c11

Please sign in to comment.