curl - 使用 wget 或 curl 下载时,VS Code 的扩展不起作用
问题描述
在我试图用来wget
下载 VS Code 扩展的远程机器上。但是,下载的文件总是损坏且无法使用。事实证明,使用wget
orcurl
将检索比使用浏览器小一点的文件,因此无法解压缩它们似乎是合理的。我用于下载的 URL 是https://marketplace.visualstudio.com/_apis/public/gallery/publishers/stkb/vsextensions/rewrap/1.9.1/vspackage
Downloads/tmp >ls -la
total 168
drwxrwxrwx 1 enno enno 4096 Feb 6 08:45 .
drwxrwxrwx 1 enno enno 4096 Feb 6 08:45 ..
-rwxrwxrwx 1 enno enno 85317 Feb 6 08:45 curl.vsix
-rwxrwxrwx 1 enno enno 85317 Feb 6 08:45 wget.vsix
BWP-181WD4:Downloads/tmp >unzip curl.vsix
Archive: curl.vsix
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
note: curl.vsix may be a plain executable, not an archive
unzip: cannot find zipfile directory in one of curl.vsix or
curl.vsix.zip, and cannot find curl.vsix.ZIP, period.
Downloads/tmp >unzip wget.vsix
Archive: wget.vsix
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
note: wget.vsix may be a plain executable, not an archive
unzip: cannot find zipfile directory in one of wget.vsix or
wget.vsix.zip, and cannot find wget.vsix.ZIP, period.
但是,使用浏览器下载的文件就可以了:
BWP-181WD4:Downloads/tmp >unzip ./browser.vsix
Archive: ./browser.vsix
inflating: extension.vsixmanifest
inflating: [Content_Types].xml
inflating: extension/CHANGELOG.md
inflating: extension/images/logo.png
inflating: extension/images/logo.svg
inflating: extension/package.json
inflating: extension/README.md
...
怎么来的?文件大小明显不同:
Downloads/tmp >ls -la
total 256
drwxrwxrwx 1 enno enno 4096 Feb 6 08:52 .
drwxrwxrwx 1 enno enno 4096 Feb 6 08:50 ..
-rwxrwxrwx 1 enno enno 90035 Feb 6 08:49 browser.vsix
-rwxrwxrwx 1 enno enno 85317 Feb 6 08:45 curl.vsix
-rwxrwxrwx 1 enno enno 85317 Feb 6 08:45 wget.vsix
这是否与如何wget
检索curl
文件或 Microsoft 如何提供这些文件有关?
解决方案
使用 wget 和 curl 下载的文件是gzip文件。
将文件名更改为vspackage.gz
并用于gunzip
提取 vsix 文件
如果您查看浏览器中的响应标头,您会看到它们是 gzip 压缩的。
为 curl/wget 找到一种使用响应标头的content-disposition
and的方法。content-encoding
推荐阅读
- assembly - x86-64 汇编:理解四字操作码 `shlq`
- c++ - 将引用绑定到指针的语法是什么?(各种)
- svg - 使用 max 函数在 svg 中使用计算值
- text - 替换 .txt 文件中的特定字符
- java - 第二个主类在 Maven 构建期间覆盖第一个主类
- python - 将返回一维数组的函数应用于 numpy 数组的所有元素
- yaml - VSTS YAML 管道 - 将项目存储库作为现有构建定义的参数传递
- sql-server-2008 - 基于某些共享列创建标识符/计数器并基于其他列分开
- image - 如何创建单个 openshift 模板来创建多个 pod(不同的应用程序)?
- mysql - MySQL,数月计算不同的元素