upload sends the file's bytes and returns the asset URL to reference from the markdown.
(ctx context.Context, a UserAsset)
| 107 | // upload sends the file's bytes and returns the asset URL to reference |
| 108 | // from the markdown. |
| 109 | func (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. |
| 118 | var openFile = func(path string) (io.ReadCloser, error) { |