MCPcopy Index your code
hub / github.com/c4milo/github-release / uploadFile

Function uploadFile

main.go:157–182  ·  view source on GitHub ↗
(uploadURL, path string)

Source from the content-addressed store, hash-verified

155}
156
157func uploadFile(uploadURL, path string) {
158 file, err := os.Open(path)
159 if err != nil {
160 log.Printf("Error: %s\n", err.Error())
161 return
162 }
163 defer file.Close()
164
165 size, err := fileSize(file)
166 if err != nil {
167 log.Printf("Error: %s\n", err.Error())
168 return
169 }
170
171 filename := filepath.Base(file.Name())
172 log.Printf("Uploading %s...\n", filename)
173 body, err := doRequest("POST", uploadURL+"?name="+filename, "application/octet-stream", file, size)
174 if err != nil {
175 log.Printf("Error: %s\n", err.Error())
176 }
177
178 if debug {
179 log.Println("========= UPLOAD RESPONSE ===========")
180 log.Println(string(body[:]))
181 }
182}
183
184// CreateRelease creates a Github Release, attaching the given files as release assets
185// If a release already exist, up in Github, this function will attempt to attach the given files to it.

Callers 1

publishReleaseFunction · 0.85

Calls 2

fileSizeFunction · 0.85
doRequestFunction · 0.85

Tested by

no test coverage detected