我正在尝试上传.zip文件
卷曲请求:
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.
我猜我的卷曲上传配置有些不对劲。可能有一些特殊的配置来上传和下载.zip文件。
我做错了什么?如何通过dropbox api以reight方式上传.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文件具有正确的文件大小,通常最好检查一下。如果文件大小与本地存储中的文件大小不同,则上传未成功完成。