upload

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUploadToken

func GetUploadToken(client *http.Client, owner, repo string) (string, error)

GetUploadToken fetches the repo page and extracts the uploadToken from the JS payload. Requires authenticated cookies in the client.

func NewClient

func NewClient(sessionCookie *http.Cookie) *http.Client

NewClient creates an http.Client with the GitHub session cookies set. GitHub requires both user_session and __Host-user_session_same_site for CSRF validation on the upload endpoint.

Types

type Result

type Result struct {
	URL      string // https://github.com/user-attachments/assets/<uuid>
	Name     string // sanitized filename
	Markdown string // ![name](url)
}

Result holds the output of a successful image upload.

func Upload

func Upload(client *http.Client, owner, repo string, repoID int, imagePath string) (*Result, error)

Upload uploads an image file to GitHub and returns the asset URL. owner/repo identifies the target repository, repoID is its numeric ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL