Upload Files to Cow Transfer with Command Line

less than 1 minute read

cowTransfer-uploader is a command line tool that can be used as part of automation, here is the example of how to get download URL and secret code:

memv2="remember-mev2=MTMzNjEyNTkyMjE6MTY0OTI0MTcyOTYyMTo4ZDQ4MDI4OWZhZjllYzFjYjc5N2Y1NWI5NDFmYzQwNg;"

cow_auth_token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiOTY3MWY4ZTUtNWIwYi00MzI1LWE0NWMtOTljMGNlNjNlYjhjIiwiZXhwIjoxNjQ4NjM2OTI5fQ.zGu-PSb4lX5aSqlpBUWp_Lhb7lxDSbGSJzw__IfiqS8"
result=$(cowtransfer-uploader -c "$memv2" -a $cow_auth_token \
                                  -s IMAGE/$image_file)

# Destination: https://cowtransfer.com/s/0badbeefcafe15
url=$(echo $result | grep -oP 'https?://[^ ]+')
# Short Download Code: coffee
code=$(echo $result | grep -oP 'Short Download Code:\s\K.*')

Before using this script, an cowtransfer account is required, after login, variable memv2 and cow_token can be retrived with the help of chrome browser:

  1. press F12
  2. Cookies can be found under Storage category Cookies