I uploaded a large file to gitub using Git LFS (Large file storage).
At first I could download the file from a direct link.
raw.githubusercontent.com/userName/reposiotry/master/file.mp4
But on the next day the file began to contain a text value
oid sha256:59f24bc922e1a48bb3feeba18b23f0e9622a7ee07166d925650d7a933283f8b1 size 123882252
How do I download this file ? How to get a direct link to it ?
Assuming that ServerAddress is for example https://api.github.com
:
ServerAddress + '/repos/RepoName/git/blobs/FileHash'
version https://git-lfs.github.com/spec/v1
oid sha256:59f24bc922e1a48bb3feeba18b23f0e9622a7ee07166d925650d7a933283f8b1
size 123882252
ServerAddress + '/repos/RepoName/contents'
{
"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": { ... }
}
url
value, and fetch it,{
"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": { ... }
}
download_url
value, and fetch it,BINARY
file content.Quote from this article,
Storage quota
If you use more than 1 GB of storage without purchasing a data pack, you can still clone repositories with large assets, but you will only retrieve the pointer files, and you will not be able to push new files back up.
I am assuming you have not purchased any additional storage for git lfs on GitHub. As you said that initially you were able to access it via this link : http://raw.githubusercontent.com/userName/reposiotry/master/file.mp4
I am guessing that you uploaded more such files which caused you to exceed your storage quota i.e 1 GB. As pointed by the article above, you will only retrieve the pointer files once you exceed the quota.
You can check if you have exceeded the limit of your storage quota here, https://github.com/settings/billing
However, if my assumptions are wrong, then you could try to get the file using this link
https://media.githubusercontent.com/media/user_name/repository_name/branch_name/file_name
You need to go into the web interface and find the raw link for your file and use that instead.
When you use Git LFS, the file that's actually stored in your repository is a pointer file like the one you see above. GitHub has different URLs to serve raw content for repository contents and Git LFS files, so if you want to get the Git LFS contents, you'll need to use the appropriate link. If you previously had the file as a non-LFS file, then the URL will have changed when you uploaded it again as an LFS file.
Just to note, using those URLs in web pages or otherwise using those direct links as a form of CDN is discouraged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With