Forum Discussion
haratsu
Oct 13, 2023Copper Contributor
DevOps Wiki: How to enable download of attachment
Hello, I do have a git based wiki in ADO with the following structure: | ---- REAGME.md
| ---- .attachments
| ---- config.xml Within README.md I want to reference config.xml in a way t...
rubenverschueren
Jul 01, 2026Copper Contributor
I got it working, kind of. I open the files in a new tab. short answer:
<a href="https://dev.azure.com/[PROJECT]/[ID]/_apis/git/repositories/[WIKI_REPO_ID]/Items?path=/.attachments/[filename]" target="_blank">[filename]</a>
longer answer. I wrote this code to download all swagger contracts from several repositories, upload them as attachments and create a wiki page that links to them:
response = await WikiHttpClient.CreateAttachmentAsync(....);
var filename = response?.Attachment.Path.Split("/").Last();
var path = $"{basePath}{filename}";
// basepath is something like this
// https://dev.azure.com/[PROJECT]/[ID]/_apis/git/repositories/[WIKI_REPO_ID]/Items?path=/.attachments/
then in markdown you can link to the path:
var sb = new StringBuilder();
sb.AppendLine($" <a href=\"{path}\" target=\"_blank\">{displayName}</a> ");
some downsides:
- the filenames have to be unique and cannot be overwritten. I used the date as a suffix.
- you'll have to clean up duplicates manually with a pull request for instance.
- the filetypes (extensions) are limited. so i uploaded my YAML files as a text file with .txt extension