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