Update Video Image

To update the video thumbnail

API URL

Please note that the API URL for video uploads is upload.dyntube.com and not api.dyntube.com.

Post the image file using HTML From

  • The file can be added to form input named "file".

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

To upload an image

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

Request Body

Name
Type
Description

file*

File

Image File

 {
        "ok": true,
        "error": null,
        "image": null
 }

Upload a File By URL

If you have a remote URL of a file, you can provide the URL to upload your video to DynTube.

  • The process is the same as uploading a normal file but instead of providing a file input, you can provide a field named url

  • An HTML Form should be posted to the following endpoint.

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

  • You can optionally provide other fields, such as projectId and planType.

To upload a video

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

Request Body

Name
Type
Description

url*

String

URL where the image is stored. This URL should directly return the image and it should not be redirected to somewhere else.

C# Sample

using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;

class Program
{
    static void Main(string[] args)
    {
        string videoId = "your_video_id";
        string bearerToken = "your_bearer_token";
        string filePath = "path/to/image.png";
        string url = $"https://upload.dyntube.com/v1/videos/image/{videoId}";

        using (var httpClient = new HttpClient())
        using (var fileStream = new FileStream(filePath, FileMode.Open))
        using (var form = new MultipartFormDataContent())
        {
            httpClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Bearer", bearerToken);

            form.Add(new StreamContent(fileStream), "file", "image.png");

            var response = httpClient.PutAsync(url, form).Result;

            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine("Video image updated successfully.");
            }
            else
            {
                Console.WriteLine($"Error updating video image. Status code: {response.StatusCode}");
            }
        }
    }
}

Node.js Sample

const fs = require('fs');
const axios = require('axios');

const videoId = 'your_video_id';
const bearerToken = 'your_bearer_token';
const filePath = 'path/to/image.png';
const url = `https://upload.dyntube.com/v1/videos/image/${videoId}`;

const config = {
    headers: {
        Authorization: `Bearer ${bearerToken}`,
        'Content-Type': 'multipart/form-data',
    }
};

const formData = new FormData();
formData.append('file', fs.createReadStream(filePath), 'image.png');

axios.put(url, formData, config)
    .then(response => {
        if (response.status === 200) {
            console.log('Video image updated successfully.');
        } else {
            console.log(`Error updating video image. Status code: ${response.status}`);
        }
    })
    .catch(error => {
        console.log(`Error updating video image. ${error}`);
    });

Python Sample

import requests

video_id = 'your_video_id'
bearer_token = 'your_bearer_token'
url = f'https://upload.dyntube.com/v1/videos/image/{video_id}'

headers = {
    'Authorization': f'Bearer {bearer_token}'
}

files = {
    'file': ('image.png', open('image.png', 'rb'), 'image/png')
}

response = requests.put(url, headers=headers, files=files)

if response.status_code == 200:
    print('Video image updated successfully.')
else:
    print(f'Error updating video image. Status code: {response.status_code}')

PHP Sample

<?php

$videoId = 'your_video_id';
$bearerToken = 'your_bearer_token';
$filePath = 'path/to/image.png';
$url = "https://upload.dyntube.com/v1/videos/image/{$videoId}";

$options = array(
    'http' => array(
        'header'  => "Authorization: Bearer {$bearerToken}\r\n",
        'method'  => 'PUT',
        'content' => file_get_contents($filePath),
    ),
);

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);

if ($response) {
    echo "Video image updated successfully.";
} else {
    echo "Error updating video image.";
}

Last updated