add func to DownloadReleaseAttachment #609
No reviewers
Labels
No Label
has/backport
has/pull
in progress
invalid
kind/breaking
kind/bug
kind/build
kind/deployment
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/proposal
kind/question
kind/refactor
kind/security
kind/testing
kind/translation
kind/ui
need/backport
priority/critical
priority/low
priority/maybe
priority/medium
reviewed/duplicate
reviewed/invalid
reviewed/wontfix
skip-changelog
status/blocked
status/needs-feedback
status/needs-reviews
status/wip
upstream/gitea
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: gitea/go-sdk#609
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "edieruby/go-sdk:download.attachment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -111,1 +111,4 @@
}
// DownloadReleaseAttachment Download an Attachment of the Release by UUID
func (c *Client) DownloadReleaseAttachment(UUID string) ([]byte, *Response, error) {
A
io.Reader
return parameter maybe better?I will update it.
@edieruby please allow "maintainers edit" on pulls :)
allowed
@ -396,6 +450,21 @@ func (c *Client) getStatusCode(method, path string, header http.Header, body io.
return resp.StatusCode, resp, nil
}
func (c *Client) getRawResponse(method, path string, header http.Header, body io.Reader) (io.ReadCloser, *Response, error) {
ther exist a
getResponseReader
already@ -303,6 +303,60 @@ func (c *Client) doRequest(method, path string, header http.Header, body io.Read
return &Response{resp}, nil
}
func (c *Client) doRawRequest(method, path string, header http.Header, body io.Reader) (*Response, error) {
why we need this?
ah you do use the web url ... as there is no api equivalent
in this case we have to refactor getWebResponse()
Used this func at the beginning.
Seems not work.
lack header setting.
different from this func.
func (c *Client) doRequest(method, path string, header http.Header, body io.Reader) (*Response, error)
edieruby/go-sdk#1
also it would be nice to have a test in place :)
Hello, I used the current func at the beginning.
It does not work.
I tested it with my local gitea.
I get the response is 404 Not Found.
It seems that this API works with auth.
gitea/client.go:224 func (c *Client) doWebRequest(method, path string, body io.Reader) (*Response, error)
This func is lack of req.Header.Set("Authorization", "token "+c.accessToken)
or req.SetBasicAuth(c.username, c.password)
well atm it only works on public repos ...
as there is no api for it it looks like
test this func against public attachments!
for private once we have to either add some roules to the web routes or else add a api dedicated download api
Download the attachment in public repo is okay.
My original purpose is download the attachment in private repo.
The gitea was deployed in my local environment, and most repos are private.
@ -112,0 +112,4 @@
// DownloadReleaseAttachment Download an Attachment of the Release by UUID
func (c *Client) DownloadReleaseAttachment(UUID string) (io.ReadCloser, *Response, error) {
if err := escapeValidatePathSegments(&UUID); err != nil {
asap there is an official api ... we could add this here instead and use the old method only as fallback
@ -232,21 +232,42 @@ func (c *Client) getWebResponse(method, path string, body io.Reader) ([]byte, *R
client := c.client // client ref can change from this point on so safe it
L230 error need to be checked
add the check
@ -248,0 +255,4 @@
// check for errors
data, err := statusCodeToErr(resp)
if err != nil {
return io.NopCloser(bytes.NewReader(data)), resp, err
if err != nil, will
data
be still kept correct content?Data will contain the error message.
It's just same with the process in getResponseReader Line:380
Pull request closed