How change the video Image using API

Please make sure that you are already familiar with our API and you have read our How to get started guide.

Here is the link to our upload API docs.

https://app.swaggerhub.com/apis-docs/dyntube.com/upload/v1

To change the video image, you need to make a HTTP PUT request to following URL.

https://upload.dyntube.com/v1/videos/image/{video-id}

  • Make sure that Authorization header is present in your headers as described in getting started guide.
  • Make sure you replace the {video-id} with actual video Id.

    

        #The Content-Type should be multipart/form-data.

        # The input name should be file

        "file": [file-contents]

    

Once a HTTP PUT request is made successfully, you should get the following response.

    
        {
        "ok": true,
        "error": null,
        "image": null
        }
    
Here are some code examples

Remember to replace {{token}} with actual values.

cURL
    

        curl --location -g --request PUT 'https://upload.dyntube.com/v1/videos/image/{video-id}' \
        --header 'Authorization: Bearer {{token}}' \
        --form 'file=@"/path/to/file"'

    
C# - using RestSharp Library
    
        var client = new RestClient("https://upload.dyntube.com/v1/videos/image/{video-id}");
        client.Timeout = -1;
        var request = new RestRequest(Method.PUT);
        request.AddHeader("Authorization", "Bearer {{token}}");
        request.AddFile("file", "/path/to/file");
        IRestResponse response = client.Execute(request);
        Console.WriteLine(response.Content);


    
NodeJs - using Axios
    

        var axios = require('axios');
        var FormData = require('form-data');
        var fs = require('fs');
        var data = new FormData();
        data.append('file', fs.createReadStream('/path/to/file'));

        var config = {
        method: 'put',
        url: 'https://upload.dyntube.com/v1/videos/image/{video-id}',
        headers: {
        'Authorization': 'Bearer {{token}}',
        ...data.getHeaders()
        },
        data : data
        };

        axios(config)
        .then(function (response) {
        console.log(JSON.stringify(response.data));
        })
        .catch(function (error) {
        console.log(error);
        });




    
PHP - HTTP_Request2



        setUrl('https://upload.dyntube.com/v1/videos');
        $request->setMethod(HTTP_Request2::METHOD_POST);
        $request->setConfig(array(
        'follow_redirects' => TRUE
        ));
        $request->setHeader(array(
        'Authorization' => 'Bearer {{token}}'
        ));
        $request->addPostParameter(array(
        'projectId' => '{{projectId}}'
        ));
        $request->addUpload('file', '/path/to/file', '/path/to/file', '
            ');
            try {
            $response = $request->send();
            if ($response->getStatus() == 200) {
            echo $response->getBody();
            }
            else {
            echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
            $response->getReasonPhrase();
            }
            }
            catch(HTTP_Request2_Exception $e) {
            echo 'Error: ' . $e->getMessage();
            }

    
PHP - cURL
    

        setUrl('https://upload.dyntube.com/v1/videos/image/{video-id}');
        $request->setMethod(HTTP_Request2::METHOD_PUT);
        $request->setConfig(array(
        'follow_redirects' => TRUE
        ));
        $request->setHeader(array(
        'Authorization' => 'Bearer {{token}}'
        ));
        $request->addUpload('file', '/path/to/file', '/path/to/file', '
            ');
            try {
            $response = $request->send();
            if ($response->getStatus() == 200) {
            echo $response->getBody();
            }
            else {
            echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
            $response->getReasonPhrase();
            }
            }
            catch(HTTP_Request2_Exception $e) {
            echo 'Error: ' . $e->getMessage();
            }


    
Python - Requests


        import requests

        url = "https://upload.dyntube.com/v1/videos"

        payload={'projectId': '{{projectId}}'}
        files=[
        ('file',('file',open('/path/to/file','rb'),'application/octet-stream'))
        ]
        headers = {
        'Authorization': 'Bearer {{token}}'
        }

        response = requests.request("POST", url, headers=headers, data=payload, files=files)

        print(response.text)



    
Ruby - Net::HTTP
    

        require "uri"
        require "net/http"

        url = URI("https://upload.dyntube.com/v1/videos/image/{video-id}")

        https = Net::HTTP.new(url.host, url.port)
        https.use_ssl = true

        request = Net::HTTP::Put.new(url)
        request["Authorization"] = "Bearer {{token}}"
        form_data = [['file', File.open('/path/to/file')]]
        request.set_form form_data, 'multipart/form-data'
        response = https.request(request)
        puts response.read_body


    
Java - Unirest
    

        Unirest.setTimeouts(0, 0);
        HttpResponse
            response = Unirest.put("https://upload.dyntube.com/v1/videos/image/{video-id}")
            .header("Authorization", "Bearer {{token}}")
            .field("file", new File("/path/to/file"))
            .asString();


    
Dart - http
    

        var headers = {
        'Authorization': 'Bearer {{token}}'
        };
        var request = http.MultipartRequest('PUT', Uri.parse('https://upload.dyntube.com/v1/videos/image/{video-id}'));
        request.files.add(await http.MultipartFile.fromPath('file', '/path/to/file'));
        request.headers.addAll(headers);

        http.StreamedResponse response = await request.send();

        if (response.statusCode == 200) {
        print(await response.stream.bytesToString());
        }
        else {
        print(response.reasonPhrase);
        }