curl - 通过 Dropbox Api 和 curl 上传 zip 文件
问题描述
我正在尝试使用上传 .zip 文件
- 保管箱 API
- 卷曲
- bash 脚本
卷曲请求:
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer <Access Token>" \
--header "Dropbox-API-Arg: {\"path\": \"/upload.zip\"}" \
--header "Content-Type: application/octet-stream" \
--data-binary @/upload.zip
上传完成,没有错误。从另一台设备(Ubuntu 服务器)下载也已完成。但是,当我尝试解压缩时,出现以下错误:
Archive: upload.zip
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.
unzip: cannot find zipfile directory in one of upload.zip or
upload.zip.zip, and cannot find upload.zip.ZIP, period.
我猜我的 curl 上传配置有些不正确。可能有一些特殊的配置可以上传和下载 .zip 文件。
我做错了什么?如何以正确的方式通过 dropbox api 上传 .zip 文件?
解决方案
一天后,我发现了问题所在。作为大多数不工作的情况,你必须检查你的代码和语法......
1)文件路径应在引号内:
--data-binary @"/upload.zip"
2) 下载路径以斜杠开头:
curl -X POST https://content.dropboxapi.com/2/files/download \
--header "Authorization: Bearer <Token>" \
--header "Dropbox-API-Arg: {\"path\": \"/directory/upload.zip\"}" >>upload.zip
一般来说,检查下载的 zip 文件是否具有正确的文件大小是个好主意。如果文件大小与本地存储不同,则上传未成功完成。
推荐阅读
- sql - 替换两个分隔符之间的子字符串或直到字符串的结尾
- python - 如果相应的 Ids 熊猫中仅存在值,则删除 NaN
- swift - Swift 4 按键访问元组
- c++ - 分配二维数组时 cudaMalloc 崩溃
- c# - 如何获取 Datagrid SelectedItem
- java - 如何将值存储在最佳 Java 集合结构中
- javascript - 如何为 Firebase 实时数据库添加自定义键?
- java - 将 Mockito 增强类与常规类进行比较
- snakemake - 我可以添加一个文件来规则所有:在输出中未定义
- arrays - 如何从 XML 文件中读取不同大小的数组?