From 974607f44efb54e7004cb3b8d046902edfeff03c Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Tue, 13 Sep 2022 17:16:01 -0700 Subject: [PATCH 1/2] Fetch file using searchDomain query so it works for views as well --- api/files.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/files.go b/api/files.go index 24a53e6..edf0005 100644 --- a/api/files.go +++ b/api/files.go @@ -26,9 +26,9 @@ 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{}{ @@ -36,7 +36,7 @@ func (f *Files) List(viewName string) ([]File, error) { } 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 { From c952a99504850274519ddd30194f64132a09e0e6 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Tue, 13 Sep 2022 17:18:04 -0700 Subject: [PATCH 2/2] File upload & download are paths and should be escaped like that --- api/files.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/files.go b/api/files.go index edf0005..d49a5b2 100644 --- a/api/files.go +++ b/api/files.go @@ -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 }) @@ -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 }