Search code examples
twiliochatx-www-form-urlencoded

Upload Media Message in Twilio Chat via REST


I can upload media/file to Twilio using REST (Python Request), however then Mime-Type is wrong and filename is null. I don't see any support for this in Twilio Python Module

Is it possible to upload the file with its filename information and right Mime Type, like VCF?

I followed this this docs, however there is no clear guidance to insert the filename


Solution

  • I was experiencing the same situation and got an answer from Twilio Support.

    Even if the docs says to set Content-Type as application/x-www-form-urlencoded, in order to be able to specify a filename, you can post the media like so:

    curl -X "POST" -H "Content-Type: multipart/form-data" -F "media=@/path/to/media.jpg;type=image/jpeg" "https://mcs.us1.twilio.com/v1/Services/<chat_instance_sid>/Media/" -u "<acount_sid>:<account_secret>"
    

    Better late than never :)