Github版本如何生成存档文件名? [英] How does Github releases generate archive filenames?

查看:113
本文介绍了Github版本如何生成存档文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在github上为我的NFQL软件创建了发行​​版。

这是发行版页面:或

b) https://codeload.github.com/vbajpai/nfql/tar.gz/v0.7



现在,如果我使用 curl / wget ,它将压缩包另存为 v0.7.ta​​r.gz 。我知道我可以在使用 curl / wget 下载时指定文件名。我想知道是否有一个可靠的github URL,我可以使用它来获取我的tarball作为 nfql-0.7.ta​​r.gz



PS:github在那儿到底在做什么?当我直接单击源代码链接时,浏览器如何更改文件名?

解决方案

第一个链接将重定向到第二个:

  curl --head https://github.com/vbajpai/nfql/archive/v0.7.ta​​r .gz 
HTTP / 1.1 302找到
位置:https://codeload.github.com/vbajpai/nfql/tar.gz/v0.7
...




直接单击
源代码时浏览器如何更改文件名


文件名是通过自定义 Content-Disposition HTTP标头定义的:

  curl --head https://codeload.github.com/vbajpai/nfql/tar.gz/v0.7 
HTTP / 1.1 200 OK
内容处置:附件; filename = nfql-0.7.ta​​r.gz
...

因此您可以使用 curl -O,-远程名称 -L,--location -J,--remote-header-name 到(分别)将输出写入到名为远程文件的文件中,遵循重定向并使用标头提供的文件名:

  curl -LOJ https://github.com/vbajpai/nfql/archive/v0.7 .tar.gz 


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

这篇关于Github版本如何生成存档文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆