mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
feat(attachment): download attachments under their own name
issue attachment download (and pr attachment download) required --output-file. It now writes ./<name> like gh release download, refusing to replace an existing file unless --clobber (or --skip-existing to keep it), with -O/--output and -D/--dir from the shared download flags. attachment list shows ID NAME SIZE DOWNLOADS CREATED with readable sizes, attachment view is a view, and upload, rename and delete report ✓ lines; delete names the attachment in its confirmation. The commands accept issue and pull request URLs and have help text with examples. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
5 files changed
+192
-126
No files matched your search
@@ -65,11 +65,13 @@ func (s Issues) UploadAttachment(ctx context.Context, number int64, name string,
|
||||
return IssueAttachment(asset), err
|
||||
}
|
||||
|
||||
// DownloadAttachment opens an attachment stream scoped to its instance and issue.
|
||||
func (s Issues) DownloadAttachment(ctx context.Context, number, id int64) (io.ReadCloser, error) {
|
||||
// DownloadAttachment opens an attachment stream scoped to its instance and issue, and returns the
|
||||
// attachment's metadata.
|
||||
func (s Issues) DownloadAttachment(ctx context.Context, number, id int64) (IssueAttachment, io.ReadCloser, error) {
|
||||
attachment, err := s.attachment(ctx, number, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return IssueAttachment{}, nil, err
|
||||
}
|
||||
return downloadAttachment(ctx, s.Client, attachment)
|
||||
body, err := downloadAttachment(ctx, s.Client, attachment)
|
||||
return IssueAttachment(assetFrom(attachment)), body, err
|
||||
}
|
||||
Reference in new issue
Block a user