import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.media.upload(['<video/image file path>',
'<video/image file path>'])
print(response)
{
    "api_id": "<api_id>",
    "objects": [
        {
            "content_type": "image/jpeg",
            "file_name": "sample_file1.jpg",
            "media_id": "<media_id>",
            "size": 85277,
            "status": "success",
            "status_code": 201,
            "upload_time": "2021-02-17T07:16:09.153289Z",
            "media_url": "https://media.plivo.com/Account/<auth_id>/Media/<media_id>"
        },
        {
            "content_type": "image/png",
            "file_name": "sample_file2.png",
            "media_id": "<media_id>",
            "size": 16709,
            "status": "success",
            "status_code": 201,
            "upload_time": "2021-02-18T11:21:55.972100055Z",
            "media_url": "https://media.plivo.com/Account/<auth_id>/Media/<media_id>"
        }
    ]
}

This API lets you upload media files to be used in sending MMS messages. Plivo supports up to 10 attachments in an upload API/SDK call with a maximum of 2MB per attachment. 

  • Media uploaded and sent to customers through MMS is saved in the system for 1 year.
  • Unused media (media that is uploaded but not used for sending an MMS message) is deleted after 6 hours.

API Endpoint

POST
https://api.plivo.com/v1/Account/{auth_id}/Media/

Headers

The content-type header should be set to multipart/form-data

Arguments

file
type(file)
Required This argument allows you to attach one or more (max 10) files as attachments in the body of the request.

Returns

Returns a JSON response containing the list of media objects uploaded.

import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.media.upload(['<video/image file path>',
'<video/image file path>'])
print(response)
{
    "api_id": "<api_id>",
    "objects": [
        {
            "content_type": "image/jpeg",
            "file_name": "sample_file1.jpg",
            "media_id": "<media_id>",
            "size": 85277,
            "status": "success",
            "status_code": 201,
            "upload_time": "2021-02-17T07:16:09.153289Z",
            "media_url": "https://media.plivo.com/Account/<auth_id>/Media/<media_id>"
        },
        {
            "content_type": "image/png",
            "file_name": "sample_file2.png",
            "media_id": "<media_id>",
            "size": 16709,
            "status": "success",
            "status_code": 201,
            "upload_time": "2021-02-18T11:21:55.972100055Z",
            "media_url": "https://media.plivo.com/Account/<auth_id>/Media/<media_id>"
        }
    ]
}