0
curl -X PUT -H 'Content-Type: video/mp4' \
         -H "Content-Length: 8036821" \
         -T "/Users/kenh/Downloads/amazing_race.mp4" \
         "https://hootsuite-video.s3.amazonaws.com/production/3563111_6923ef29-d2bd- 4b2a-a6d2-11295411c988.mp4?AWSAccessKeyId=AKIAIHSDDN2I7V2FDJGA&Expires=1465846288&Signature=3xLFijSn02YIx6AOOjmri5Djkko%3D"

Mainly I do not understand how to user -T line. Headers and URL I know.

AKX
  • 152,115
  • 15
  • 115
  • 172
Naqi
  • 135
  • 12

2 Answers2

1

-T is documented as follows:

-T, --upload-file <file>
    This  transfers  the  specified  local  file  to the remote URL. [...] If this is used on an HTTP(S) server, the PUT command will be used.

With that in mind, the requests invocation, based on the Streaming Uploads doc, should be approximately

import requests

with open("/Users/kenh/Downloads/amazing_race.mp4", "rb") as data:
    resp = requests.put(
        url="https://....",
        data=data,
        headers={
            "Content-type": "video/mp4",
        },
    )
    resp.raise_for_status()

Requests will divine the content-length header for you if it can.

AKX
  • 152,115
  • 15
  • 115
  • 172
1

What your command trying to do is to upload a file to a HTTP server. So -T is actually the short version of the --upload-file argument and the file name that follows it is the one you want to upload.

requests is almost the equivalent package in Python. If you want to convert CURL syntax to Python check this site.

R. Marolahy
  • 1,325
  • 7
  • 17