Dropbox使用cURL上传多个文件?

时间:2017-10-08 12:16:08

标签: curl dropbox dropbox-api

所以我有多个.sav文件要上传到我的Dropbox 我已经创建了一个应用并拥有一个访问令牌

这是我现在的代码 如何将其名称上传到我的Dropbox的所有文件

curl -X POST https://content.dropboxapi.com/2/files/alpha/upload \
  --header 'Authorization: Bearer <access-token>' \
  --header 'Content-Type: application/octet-stream' \
  --header 'Dropbox-API-Arg: {"path":"","mode":{".tag":"add"}}' \
  --data-binary @'test.sav'

2 个答案:

答案 0 :(得分:1)

只需尝试

#!/bin/bash

for file in ayam*.txt
do
 curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Dropbox-API-Arg: {\"path\": \"/${file}\"}" \
--header "Content-Type: application/octet-stream" \
--data-binary "@${file}"
done;

答案 1 :(得分:0)

尝试循环:

$ for i in *.sav; do echo ${i}; done

如果可行,则应打印您要上传的名称,然后将echo ${i}替换为curl命令:

$ for i in *.sav; do \
curl -X POST https://content.dropboxapi.com/2/files/alpha/upload \
--header 'Authorization: Bearer <access-token>' \
--header 'Content-Type: application/octet-stream' \
--header 'Dropbox-API-Arg: {"path":"","mode":{".tag":"add"}}' \
--data-binary "@${i}"
done