UploadAndAttach uploads assets in order and stops at the first failure. It points existing references at the URLs of successful uploads and appends only successful uploads the markdown did not reference. Assets after a failure are not attempted. It is UploadAndAttachDocuments with md as the only doc
(ctx context.Context, md, markdownDir string, assets []UserAsset)
| 83 | // The markdown is returned unchanged when it could not be rewritten, so a |
| 84 | // caller that assigns the result in place never destroys what it was given. |
| 85 | func (u *Uploader) UploadAndAttach(ctx context.Context, md, markdownDir string, assets []UserAsset) (string, UploadResult, error) { |
| 86 | results, err := u.UploadAndAttachDocuments(ctx, []Document{{Markdown: md, Dir: markdownDir}}, assets) |
| 87 | if len(results) == 0 { |
| 88 | return md, UploadResult{}, err |
| 89 | } |
| 90 | r := results[0] |
| 91 | return r.Markdown, UploadResult{ |
| 92 | Uploaded: len(r.Uploaded), |
| 93 | AppendOperations: r.AppendOperations, |
| 94 | ReplaceOperations: r.ReplaceOperations, |
| 95 | }, err |
| 96 | } |
| 97 | |
| 98 | // UploadAndAttachDocuments attaches one set of files to several documents at |
| 99 | // once. It uploads each file once, in order, and stops at the first failure. |