feat: Add UploadReleaseAssetFromRelease convenience helper by rockygeekz · Pull Request #3851 · google/go-github

@rockygeekz

@gmlewis changed the title repos: add UploadReleaseAssetFromRelease convenience helper feat: Add UploadReleaseAssetFromRelease convenience helper

Dec 4, 2025

alexandear

@rockygeekz

gmlewis

klaernie

@rockygeekz

…bsolute upload URLs

This adds a convenience helper that uploads a release asset using the
UploadURL returned in RepositoryRelease.

Changes included:
- Accept io.Reader + size instead of *os.File (consistent with NewUploadRequest)
- Strip only the URI-template portion
- Preserve absolute upload URLs exactly as provided (no path rewriting)
- Add comprehensive tests for all branches (nil release, nil reader, negative size,
  absolute URLs, media type override, bad options, and upload success cases)

This behavior ensures correct handling of GitHub Enterprise upload endpoints
and aligns with the intent described in google#3849.

Fixes google#3849.

alexandear

@rockygeekz

- Preserve absolute upload URLs exactly as returned by the API
- Trim only the URI-template portion
- Align media-type resolution with UploadReleaseAsset
- Update tests to cover all branches and BaseURL-prefixed paths
- Improve error coverage using existing test helpers

alexandear

alexandear

ruidazeng

@rockygeekz

@rockygeekz

klaernie

@rockygeekz

@rockygeekz

alexandear