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

Method upload

internal/attachments/client.go:109–115  ·  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

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