Download LFS file content (not pointer) with API

Added comment on an older topic so feel free to close this one if that is still alive.

It doesn’t appear that there is a way to download the file contents of an LFS tracked file using the repository files api. https://docs.gitlab.com/ee/api/repository_files.html

What this ends up returning is the content of the pointer file, for both the content field of the get_file endpoint https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository and also the content of the get_raw_file endpoint https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository.

How can one programmatically, through an HTTP(S) call retrieve the contents of an LFS tracked file?

I am not familiar with LFS. Can you do what you want to do using the GitLab web app? If so, you may be able to use an internal API normally used by the web app, authenticated by personal access tokens.

Funny you mentioned this. I just came back to update this topic.

Noted that the web app supported downloading the files as one would expect. So just used the download url for the application and passed in the same API token header that the API requires and it worked as expected.

Yep, indeed. I’ve found the same for the Docker registry, which doesn’t seem to have endpoints in the formal API. I’ve asked a question to see if anyone knows how stable the “hidden” API is :wink: