Retrieve Media

    This API lets you retrieve a media file uploaded, sent or received by the user.

    API Endpoint

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

    Arguments

    No arguments need to be passed.

    Returns

    This API call returns the details of the media files identified by the media_uuid specified in the request URL.

    Response

    HTTP Status Code: 200

    {
        "api_id": "<api_id>",
        "content_type": "image/png",
        "file_name": "SampleFile.png",
        "media_id": "<media_id>",
        "size": 700670,
        "upload_time": "2020-02-17T07:53:36.643522Z",
        "media_url": "https://media.plivo.com/Account/<auth_id>/Media/<media_id>"
    }
    

    Example Request

    1
    2
    3
    4
    
    import plivo
    client = plivo.RestClient("<auth_id>", "<auth_token>")
    response = client.media.get('media_id')
    print(response)
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("AUTH_ID", "AUTH_TOKEN")
    begin
     response = api.media.get('media_id')
     puts response
     rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    let plivo = require('plivo');
    
    let client = new plivo.Client('<auth_id>', '<auth_token>');
    client.media.get("<media_id>").then(
      function (media) {
        console.log("\n============ response ===========\n", media)
      }
    ).catch(function (response) {
      console.log("\n============ Error :: ===========\n", response);
    });
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    
    <?php
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    
    $client = new RestClient("AUTH_ID", "AUTH_TOKEN");
    $client->client->setTimeout(40);
    
    
    // Get a paticular Media
    try {
        $response = $client->media->get('<media_id>');
         print_r($response);
     }
     catch (PlivoRestException $ex) {
         print_r($ex);
     }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    package com.plivo.api;
    import java.io.IOException;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.base.ListResponse;
    import com.plivo.api.models.media.Media;
    
    public class Test {
      public static void main(String[] args) {
        Plivo.init("AUTH_ID", "AUTH_TOKEN");
        try {
          Media p = Media.getter("media_id").get();
          System.out.println(p);
        } catch (IOException e) {
          e.printStackTrace();
        } catch (PlivoRestException e) {
          e.printStackTrace();
        }
      }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    using System;
    using Plivo;
    using Plivo.Exception;
    
    namespace SdkTestDotnet
    {
        class Program
        {
            static void Main(string[] args)
            {
                var api = new PlivoApi("AUTH_ID", "AUTH_TOKEN");
                try
                {
                    var response = api.Media.Get("media_id");
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    
    package main
    
    import (
            "fmt"
    
            plivo "github.com/plivo/plivo-go"
    )
    
    func main() {
    
            // MAIN ACCOUNT
            client, err := plivo.NewClient("AUTH_ID",
                    "AUTH_TOKEN",
                    &plivo.ClientOptions{})
            if err != nil {
                    panic(err)
            }
    
    // get a specific media
            getResp, err := client.Media.Get("<media_id>")
            if err != nil {
                    panic(err)
            }
            fmt.Printf("Response: %#v\n", getResp)
    }