通过批处理 file/cmd 下载的 Zip 文件已损坏
Zip file downloaded via batch file/cmd is corrupted
curl -o ./Makent-files.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip" --ssl-no-revoke
下载的 zip 文件已损坏
我会使用参数“-L”/“--location”来指示 curl 跟随位置。
示例:
$ curl -L -o ./Makent-files.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip"
$ zipinfo Makent-files.zip
Archive: Makent-files.zip
Zip file size: 9948 bytes, number of entries: 2
drwx--- 0.0 fat 0 bx stor 21-Dec-29 11:20 Makent-files/
-rw---- 0.0 fat 105662 bx defN 21-Dec-29 11:20 Makent-files/Makent.ico
2 files, 105662 bytes uncompressed, 9626 bytes compressed: 90.9%
curl 手册页摘录:
-L, --location
(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with
-i, --include or -I, --head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it will not be able to in‐
tercept the user+password. See also --location-trusted on how to change this. You can limit the amount of redirects to follow by using the --max-redirs option.
When curl follows a redirect and if the request is a POST, it will send the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl will re-send the following request
using the same unmodified method.
You can tell curl to not change POST requests to GET after a 30x response by using the dedicated options for that: --post301, --post302 and --post303.
The method set with -X, --request overrides the method curl would otherwise select to use.
Example:
curl -L https://example.com
参考:https://curl.se/docs/manpage.html
使用示例扩展@SomethingDark 的评论的更广泛的解释
# downloading the file without following the location - we are downloading a html file
$ curl -o ./Makent-files-without-minusL.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip"
# downloading the file with following the location - we are downloading the zip file befind the location redirect.
$ curl -L -o ./Makent-files-with-minusL.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip"
# one file on your disk is a zip file and the other one the html file
$ file *
Makent-files-with-minusL.zip: Zip archive data, at least v1.0 to extract, compression method=store
Makent-files-without-minusL.zip: HTML document, ASCII text, with no line terminators
curl -o ./Makent-files.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip" --ssl-no-revoke
下载的 zip 文件已损坏
我会使用参数“-L”/“--location”来指示 curl 跟随位置。 示例:
$ curl -L -o ./Makent-files.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip"
$ zipinfo Makent-files.zip
Archive: Makent-files.zip
Zip file size: 9948 bytes, number of entries: 2
drwx--- 0.0 fat 0 bx stor 21-Dec-29 11:20 Makent-files/
-rw---- 0.0 fat 105662 bx defN 21-Dec-29 11:20 Makent-files/Makent.ico
2 files, 105662 bytes uncompressed, 9626 bytes compressed: 90.9%
curl 手册页摘录:
-L, --location
(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with
-i, --include or -I, --head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it will not be able to in‐
tercept the user+password. See also --location-trusted on how to change this. You can limit the amount of redirects to follow by using the --max-redirs option.
When curl follows a redirect and if the request is a POST, it will send the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl will re-send the following request
using the same unmodified method.
You can tell curl to not change POST requests to GET after a 30x response by using the dedicated options for that: --post301, --post302 and --post303.
The method set with -X, --request overrides the method curl would otherwise select to use.
Example:
curl -L https://example.com
参考:https://curl.se/docs/manpage.html
使用示例扩展@SomethingDark 的评论的更广泛的解释
# downloading the file without following the location - we are downloading a html file
$ curl -o ./Makent-files-without-minusL.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip"
# downloading the file with following the location - we are downloading the zip file befind the location redirect.
$ curl -L -o ./Makent-files-with-minusL.zip "https://github.com/Mapagmataas/Makent/archive/refs/heads/files.zip"
# one file on your disk is a zip file and the other one the html file
$ file *
Makent-files-with-minusL.zip: Zip archive data, at least v1.0 to extract, compression method=store
Makent-files-without-minusL.zip: HTML document, ASCII text, with no line terminators