[PR #3478] [MERGED] Add Attachment API #16959

Closed
opened 2025-11-02 12:23:01 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/3478
Author: @jonasfranz
Created: 2/8/2018
Status: Merged
Merged: 3/6/2018
Merged by: @appleboy

Base: masterHead: 711-releases-api


📝 Commits (10+)

  • 25615b1 Add Attachment API
  • b2a780d Add unit tests for new attachment functions
  • 1407c1c fix lint
  • 80c6555 Update vendor.json
  • ea14f48 Merge remote-tracking branch 'origin/711-releases-api' into 711-releases-api
  • 95965d8 remove version of sdk
  • 640ef5a Fix unit tests
  • ad41258 Add CreateReleaseAttachment
  • ca954a7 Add filename query parameter for choosing another name for an attachment
  • 151f594 Fix order of imports

📊 Changes

30 files changed (+1043 additions, -122 deletions)

View changed files

📝 models/attachment.go (+65 -2)
📝 models/attachment_test.go (+29 -0)
📝 models/release.go (+6 -1)
📝 package.json (+1 -1)
📝 public/swagger.v1.json (+387 -1)
📝 routers/api/v1/api.go (+12 -3)
📝 routers/api/v1/repo/release.go (+2 -2)
routers/api/v1/repo/release_attachment.go (+322 -0)
📝 routers/api/v1/swagger/options.go (+2 -0)
📝 routers/api/v1/swagger/repo.go (+12 -0)
📝 vendor/code.gitea.io/sdk/gitea/admin_user.go (+14 -14)
📝 vendor/code.gitea.io/sdk/gitea/attachment.go (+83 -8)
📝 vendor/code.gitea.io/sdk/gitea/gitea.go (+3 -0)
📝 vendor/code.gitea.io/sdk/gitea/hook.go (+13 -13)
📝 vendor/code.gitea.io/sdk/gitea/issue.go (+10 -10)
📝 vendor/code.gitea.io/sdk/gitea/issue_comment.go (+8 -8)
📝 vendor/code.gitea.io/sdk/gitea/issue_label.go (+3 -3)
📝 vendor/code.gitea.io/sdk/gitea/issue_milestone.go (+11 -11)
📝 vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go (+1 -1)
📝 vendor/code.gitea.io/sdk/gitea/org.go (+4 -4)

...and 10 more files

📄 Description

Fixes #711

Blocked by go-gitea/go-sdk#90

API endpoints:

  • GET repos/:owner/:repo/releases (add attachments)
  • GET repos/:owner/:repo/releases/:id (add attachments)
  • GET repos/:owner/:repo/releases/:id/assets
  • GET repos/:owner/:repo/releases/:id/assets/:attachment_id
  • POST repos/:owner/:repo/releases/:id/assets
  • PATCH repos/:owner/:repo/releases/:id/assets/:attachment_id
  • DELETE repos/:owner/:repo/releases/:id/assets/:attachment_id

Example response

[
   {
      "id":1,
      "tag_name":"test",
      "target_commitish":"master",
      "name":"",
      "body":"test",
      "url":"http://localhost:3000/api/v1/jonas/re/releases/1",
      "tarball_url":"http://localhost:3000/jonas/re/archive/test.tar.gz",
      "zipball_url":"http://localhost:3000/jonas/re/archive/test.zip",
      "draft":false,
      "prerelease":false,
      "created_at":"2018-02-08T21:17:42+01:00",
      "published_at":"2018-02-08T21:17:42+01:00",
      "author":{
         "id":1,
         "login":"jonas",
         "full_name":"",
         "email":"admin@admin.admin",
         "avatar_url":"https://secure.gravatar.com/avatar/839531d0faa3e6efb8d874dd74a8e530?d=identicon",
         "username":"jonas"
      },
      "assets":[
         {
            "id":1,
            "name":"device manager.PNG",
            "size":9453,
            "download_count":1,
            "created_at":"2018-02-08T21:17:39+01:00",
            "uuid":"b780ab51-c0f2-4c6e-b16c-12fe07636d52",
            "browser_download_url":"http://localhost:3000/attachments/b780ab51-c0f2-4c6e-b16c-12fe07636d52"
         }
      ]
   }
]

TODO

  • Unit tests

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/3478 **Author:** [@jonasfranz](https://github.com/jonasfranz) **Created:** 2/8/2018 **Status:** ✅ Merged **Merged:** 3/6/2018 **Merged by:** [@appleboy](https://github.com/appleboy) **Base:** `master` ← **Head:** `711-releases-api` --- ### 📝 Commits (10+) - [`25615b1`](https://github.com/go-gitea/gitea/commit/25615b1430ddfdb6efeb3482bc71d0b0feb1b4d0) Add Attachment API - [`b2a780d`](https://github.com/go-gitea/gitea/commit/b2a780dec5fc723a02d7c9fbc040971a0ff524ba) Add unit tests for new attachment functions - [`1407c1c`](https://github.com/go-gitea/gitea/commit/1407c1c467a8d9617b810b1cccdccee00a6a1a4c) fix lint - [`80c6555`](https://github.com/go-gitea/gitea/commit/80c655574d3a16b2410c9be772846fcd64fb91c5) Update vendor.json - [`ea14f48`](https://github.com/go-gitea/gitea/commit/ea14f48aaeff6912c9cde12f0b71bebc6061ee4c) Merge remote-tracking branch 'origin/711-releases-api' into 711-releases-api - [`95965d8`](https://github.com/go-gitea/gitea/commit/95965d8da17616e1e266fe5d47d537b5e7bc1b90) remove version of sdk - [`640ef5a`](https://github.com/go-gitea/gitea/commit/640ef5a3c53f2fc61109e1c31a156259f5033aec) Fix unit tests - [`ad41258`](https://github.com/go-gitea/gitea/commit/ad412582e8dfeae78977041448a3d02ba1f05c95) Add CreateReleaseAttachment - [`ca954a7`](https://github.com/go-gitea/gitea/commit/ca954a7c168b7117227f1b458ae276b14ae8fab0) Add filename query parameter for choosing another name for an attachment - [`151f594`](https://github.com/go-gitea/gitea/commit/151f59481ada22ac06cf9ed44cb2122e59c68b6e) Fix order of imports ### 📊 Changes **30 files changed** (+1043 additions, -122 deletions) <details> <summary>View changed files</summary> 📝 `models/attachment.go` (+65 -2) 📝 `models/attachment_test.go` (+29 -0) 📝 `models/release.go` (+6 -1) 📝 `package.json` (+1 -1) 📝 `public/swagger.v1.json` (+387 -1) 📝 `routers/api/v1/api.go` (+12 -3) 📝 `routers/api/v1/repo/release.go` (+2 -2) ➕ `routers/api/v1/repo/release_attachment.go` (+322 -0) 📝 `routers/api/v1/swagger/options.go` (+2 -0) 📝 `routers/api/v1/swagger/repo.go` (+12 -0) 📝 `vendor/code.gitea.io/sdk/gitea/admin_user.go` (+14 -14) 📝 `vendor/code.gitea.io/sdk/gitea/attachment.go` (+83 -8) 📝 `vendor/code.gitea.io/sdk/gitea/gitea.go` (+3 -0) 📝 `vendor/code.gitea.io/sdk/gitea/hook.go` (+13 -13) 📝 `vendor/code.gitea.io/sdk/gitea/issue.go` (+10 -10) 📝 `vendor/code.gitea.io/sdk/gitea/issue_comment.go` (+8 -8) 📝 `vendor/code.gitea.io/sdk/gitea/issue_label.go` (+3 -3) 📝 `vendor/code.gitea.io/sdk/gitea/issue_milestone.go` (+11 -11) 📝 `vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go` (+1 -1) 📝 `vendor/code.gitea.io/sdk/gitea/org.go` (+4 -4) _...and 10 more files_ </details> ### 📄 Description Fixes #711 ~~Blocked by go-gitea/go-sdk#90~~ ## API endpoints: * GET repos/:owner/:repo/releases (add attachments) * GET repos/:owner/:repo/releases/:id (add attachments) * GET repos/:owner/:repo/releases/:id/assets * GET repos/:owner/:repo/releases/:id/assets/:attachment_id * POST repos/:owner/:repo/releases/:id/assets * PATCH repos/:owner/:repo/releases/:id/assets/:attachment_id * DELETE repos/:owner/:repo/releases/:id/assets/:attachment_id ## Example response ```json [ { "id":1, "tag_name":"test", "target_commitish":"master", "name":"", "body":"test", "url":"http://localhost:3000/api/v1/jonas/re/releases/1", "tarball_url":"http://localhost:3000/jonas/re/archive/test.tar.gz", "zipball_url":"http://localhost:3000/jonas/re/archive/test.zip", "draft":false, "prerelease":false, "created_at":"2018-02-08T21:17:42+01:00", "published_at":"2018-02-08T21:17:42+01:00", "author":{ "id":1, "login":"jonas", "full_name":"", "email":"admin@admin.admin", "avatar_url":"https://secure.gravatar.com/avatar/839531d0faa3e6efb8d874dd74a8e530?d=identicon", "username":"jonas" }, "assets":[ { "id":1, "name":"device manager.PNG", "size":9453, "download_count":1, "created_at":"2018-02-08T21:17:39+01:00", "uuid":"b780ab51-c0f2-4c6e-b16c-12fe07636d52", "browser_download_url":"http://localhost:3000/attachments/b780ab51-c0f2-4c6e-b16c-12fe07636d52" } ] } ] ``` ## TODO - [x] Unit tests --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:23:01 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#16959