Today I was looking for the same answer, did not found any specific enough to solve the problem, so I was digging on my own and found this:
Assuming that ServerAddres is for example https://api.github.com
:
- if You konw Your RepoName ('UserName/ReposiotryName' pair) and FileHash,
then You fetch: ServerAddres + '/repos/RepoName/git/blobs/FileHash'
and if in response You have:
version https://git-lfs.github.com/spec/v1
oid sha256:59f24bc922e1a48bb3feeba18b23f0e9622a7ee07166d925650d7a933283f8b1
size 123882252
- than You must search in contents of Your repository for matching FileHash,
fetching: ServerAddres + '/repos/RepoName/contents'
and in response You have:
{
"name": "filename.ext",
"path": "path/filename.ext",
"sha": "FileHash",
"size": 42,
"url": "https://api.github.com/repos/RepoName/contents/path/filename.ext?ref=master",
"html_url": "...",
"git_url": "...",
"download_url": "...",
"type": "file",
"_links": { ... }
}
- now You take
url
value, and fetch it,
in response You have:
{
"name": "filename.ext",
"path": "path/filename.ext",
"sha": "FileHash",
"size": 720896,
"url": "...",
"html_url": "...",
"git_url": "...",
"download_url": "https://media.githubusercontent.com/media/RepoName/RepoHash/path/filename.ext?token=...",
"type": "file",
"content": "...", // same as response from pt. 1
"encoding": "base64",
"_links": { ... }
}
- now You take
download_url
value, and fetch it,
in response You should have BINARY
file content.
That's it.