API: Download LFS file

Hello everyone!

I’m trying to download a LFS file, the raw file content is something like this:

version https://git-lfs.github.com/spec/v1
oid sha256:0ba4240dc67dd86fd382b31b14fd1569bce816fe8a71e2234cefac720e724caa
size 2119180

I can download that raw content by using the following command:

curl --request GET --header 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' 'https://gitlab.example.com/api/v3/projects/13083/repository/files?file_path=app/models/key.rb&ref=master'

(from https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository)

But what I need is the content the file is targeting.

I did the same for GitHub in the past, they provide you with a download URL to get the real file content, I can’t find how to do it for GitLab.

Please help!



Another similar problem:

I tried to download the zip file of a repo with LFS enabled.

Then I unarchived it and only to find that all the LFS-tracked files are all 130 bytes size link files. I still need to recover them to real files.

It’s better that Gitlab helps me do that before the downloading task start.

[I know this is an old post BUT…]

+1 I am running into this exact issue. Need to resolve actual file contents and not the pointer.

Searching through forum, it isn’t clear if this has ever been resolved.

You can use the same authentication that the API uses, but instead of using hte api endpoints, use the URLs that the web app uses to download files.