Forum Discussion

haratsu's avatar
haratsu
Copper Contributor
Oct 13, 2023

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 that:

1. enforces the file to be downloaded and not opened

2. ensures a meaningful file name proposal for the download

 

For "common" markdown this would be something like:

...
[Config](./.attachments/config.xml?download=true&name=config.xml)
...

 

unfortunately ADO performs some URL-encoding to this relative link and tries to find a file named:
- ./attachments/config.xml%3Fdownload%3Dtrue%26name%3Dconfig.xml

This file cannot be found (why should it, such a file does not exist)

 

My questions are:

1. How to properly format the relative link in ADO markdown to make the attachment downloadable

2. How to properly format the relative link in ADO markdown to define the attachments name

 

Exclusion:

- The answer "Use an absolute link like https://..../" is not an option as no-one will ever be able to maintain this across multiple branches

 

Thank you in advance 😉

  • mohammedmubeen's avatar
    mohammedmubeen
    Copper Contributor

    haratsu 

    ADO markdown to make an attachment downloadable

     

    [Config](./.attachments/config.xml?download=true)

     

     

    To define the attachment

     

    [Config](./.attachments/config.xml?download=true&fileName=my-config.xml)

     

    • haratsu's avatar
      haratsu
      Copper Contributor

      mohammedmubeen 

      Thanks for your reply, but as mentioned in my initial post this is what i already tried. ADO is messing up the url when using your approach resulting in the folloing error:

      {
        "$id":"1",
        "innerException":null,
        "message":"TF401174: The item 'wiki/.attachments/config.xml?download=true&fileName=config.xml' could not be found in the repository '<nonOfYourBusiness>' at the version specified by '<Branch: feature/2191 >' (resolved to commit '1dfc...bfd4')",
        "typeName":"Microsoft.TeamFoundation.Git.Server.GitItemNotFoundException, Microsoft.TeamFoundation.Git.Server",
        "typeKey":"GitItemNotFoundException",
        "errorCode":0,
        "eventId":3000
      }

       

      The reason for that - as mentioned above - is that the resulting url contains no real url parameters but encodes any char "?" or "&" as utf escaped char:

      https://.../_apis/git/repositories/.../Items?path=/wiki/.attachments/config.xml%3Fdownload%3Dtrue%26fileName%3Dconfig.xml&download=false&resolveLfs=true&%24format=octetStream&api-version=5.0-preview.1&sanitize=true&versionDescriptor.version=feature/2191

       

Resources