【问题标题】:Using CURL to upload to Dropbox and overwrite a file使用 CURL 上传到 Dropbox 并覆盖文件
【发布时间】:2018-03-29 06:09:07
【问题描述】:

我是一名小型管理员,我会说 Linux 的入门级。我正在尝试使用 CURL 将一个小型备份 sqlitedb 上传到 Dropbox,并且第一次上传已经成功,但是,我正在尝试每 30 分钟将一个文件上传到 Dropbox,并用来自的新文件覆盖 DROPBOX 中的当前文件我的 Linux 服务器(作为我的 Teamspeak 数据库的 jerry-rigged 异地备份)

这是我到目前为止的代码:

curl -X PUT https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer <dropbox code here>" \
--header "Dropbox-API-Arg: {\"path\": \"/home/ec2-user/ts3server.sqlitedb.bz2\"}" \
--header "Content-Type: application/octet-stream" \
--data-binary ts3server.sqlitedb.bz2

运行该代码一次后,它不会使用更新的文件覆盖我的 Dropbox 帐户中的当前文件。任何帮助表示赞赏

【问题讨论】:

    标签: linux amazon-web-services curl amazon-ec2 dropbox


    【解决方案1】:

    您需要将mode 与参数overwrite 一起使用。默认为add

    添加 - 如果存在冲突,请勿覆盖现有文件。自动重命名策略是在文件名后附加一个数字。为了 例如,“document.txt”可能会变成“document (2).txt”。

    覆盖 - 始终覆盖现有文件。自动重命名策略与添加相同。

    参考:/upload

    curl -X POST https://content.dropboxapi.com/2/files/upload \
        --header "Authorization: Bearer " \
        --header "Dropbox-API-Arg: {\"path\": \"/Homework/math/Matrices.txt\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}" \
        --header "Content-Type: application/octet-stream" \
        --data-binary @local_file.txt
    

    【讨论】:

    • 我现在收到一个错误:代码'警告:无法从文件“ts3server.sqlitedb.bz2”中读取数据,这会导致警告:空 POST。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    • 2011-12-25
    • 1970-01-01
    • 2011-08-27
    • 2023-03-17
    • 2016-06-30
    相关资源
    最近更新 更多