Skip to content

Instantly share code, notes, and snippets.

@lokori
Created April 24, 2018 05:35
Show Gist options
  • Save lokori/36afff86ba2852c0bbb0e4945e23ddc3 to your computer and use it in GitHub Desktop.
Save lokori/36afff86ba2852c0bbb0e4945e23ddc3 to your computer and use it in GitHub Desktop.
Mass file upload with curl. This is for a specific application, but can be adapted for others.
#!/bin/bash
upload_file () {
SESSION=df831243-602e-4c27-8afe-09a6760be8ad
XSRF=83872690-237b-c176-8830-ac11ba76d7b3
URL="http://192.168.50.1:8080/api/UPLOOOD"
echo "Handling file $1"
curl -v -i -X POST -H "Content-Type: multipart/form-data" -H "Cookie: ring-session=$SESSION; XSRF-TOKEN=$XSRF" -F "file=@$1;type=application/vnd.openxmlformats-officedocument.s\
preadsheetml.sheet" -F "x-xsrf-token=$XSRF" $URL >> logifile.txt 2>&1
echo "-----------------------" >> logifile.txt
}
export -f upload_file
find . -name "*.xlsx"|xargs -I {} bash -c 'upload_file {}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment