I just created releases for my NFQL software on github.
Here is the releases page: https://github.com/vbajpai/nfql/releases
For the latest release, v0.7
. If I click on the tarball button, it saves a nfql-0.7.tar.gz
. This is great and exactly how I want my release archives to be named.
However, I need the download link of the tarball itself. So that I can create a MacPorts/Homebrew file for the tarball. If I look at the download link, it is:
a) https://github.com/vbajpai/nfql/archive/v0.7.tar.gz or
b) https://codeload.github.com/vbajpai/nfql/tar.gz/v0.7
now if I use curl/wget
it saves the tarball as v0.7.tar.gz
. I know I can specify a filename while downloading using curl/wget
. I want to know is there is a reliable github URL I can use to fetch my tarball as nfql-0.7.tar.gz
.
PS: What is github doing there anyway? How is the filename altered by the browsers when I directly click the source code link?
The first link gives a redirection to the second one:
curl --head https://github.com/vbajpai/nfql/archive/v0.7.tar.gz
HTTP/1.1 302 Found
Location: https://codeload.github.com/vbajpai/nfql/tar.gz/v0.7
...
How is the filename altered by the browsers when I directly click the source code link?
The filename is defined via a custom Content-Disposition
HTTP header:
curl --head https://codeload.github.com/vbajpai/nfql/tar.gz/v0.7
HTTP/1.1 200 OK
Content-Disposition: attachment; filename=nfql-0.7.tar.gz
...
So you can use curl
's -O, --remote-name
, -L, --location
and -J, --remote-header-name
to (resp.) write output to a file named as the remote file, follow redirects and use the header-provided filename:
curl -LOJ https://github.com/vbajpai/nfql/archive/v0.7.tar.gz
Not sure if this worked when the question was originally posted, but now you can use https://github.com/vbajpai/nfql/archive/v0.7/nfql-0.7.tar.gz to get the correct filename directly without looking at headers. This is very nice when using wget as you need no flags, just simply wget https://github.com/vbajpai/nfql/archive/v0.7/nfql-0.7.tar.gz
Note that it is the next-to-last path component that selects the release to use - you can put whatever filename you want to have as the last path component.
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