Reputation: 64
So I have multiple .sav files that I want to upload to my Dropbox I already created an app and have an access token
This is the code i have right now How can I make it upload all file with their name to my 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'
Upvotes: 0
Views: 923
Reputation: 11
Just try this
#!/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;
Upvotes: 1
Reputation: 26925
Give a try to a loop:
$ for i in *.sav; do echo ${i}; done
If that works, it should print the names you will like to upload, then just replace echo ${i}
with your curl
command:
$ 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
Upvotes: 0