upload sends the file's bytes and returns the asset URL to reference from the markdown.
(ctx context.Context, a UserAsset)
| 86 | // upload sends the file's bytes and returns the asset URL to reference |
| 87 | // from the markdown. |
| 88 | func (u *Uploader) upload(ctx context.Context, a UserAsset) (string, error) { |
| 89 | assetURL, err := u.postAsset(ctx, a.getAsset()) |
| 90 | if err != nil { |
| 91 | return "", newUploadError(err, a) |
| 92 | } |
| 93 | return assetURL, nil |
| 94 | } |
| 95 | |
| 96 | // openFile is indirected so tests can stub file opening. |
| 97 | var openFile = func(path string) (io.ReadCloser, error) { |