MCPcopy Create free account
hub / github.com/cli/cli / upload

Method upload

internal/attachments/client.go:110–116  ·  view source on GitHub ↗

upload sends the file's bytes and returns the asset URL to reference from the markdown.

(ctx context.Context, a UserAsset)

Source from the content-addressed store, hash-verified

108// upload sends the file's bytes and returns the asset URL to reference
109// from the markdown.
110func (u *Uploader) upload(ctx context.Context, a UserAsset) (string, error) {
111 assetURL, err := u.postAsset(ctx, a.getAsset())
112 if err != nil {
113 return "", newUploadError(err, a)
114 }
115 return assetURL, nil
116}
117
118// openFile is indirected so tests can stub file opening.
119var openFile = func(path string) (io.ReadCloser, error) {

Callers 6

UploadAndAttachMethod · 0.95
TestUploadAuthenticationFunction · 0.95
TestUploadFunction · 0.80
TestUploadHostForTenantFunction · 0.80
TestUploadErrorsFunction · 0.80
TestUploadMissingFileFunction · 0.80

Calls 3

postAssetMethod · 0.95
newUploadErrorFunction · 0.85
getAssetMethod · 0.65

Tested by 5

TestUploadAuthenticationFunction · 0.76
TestUploadFunction · 0.64
TestUploadHostForTenantFunction · 0.64
TestUploadErrorsFunction · 0.64
TestUploadMissingFileFunction · 0.64