DynTube API
  • Welcome!
  • Key Concepts
  • Quick Start
  • Reference
    • Videos
      • Video Upload via File (Server Side)
      • Video Upload via URL (server side)
      • HTML-Form Client Side Video Uploads
      • Get Video Status
      • Get Videos
      • Get Video
      • Update Video
      • Delete Video
      • Download Original Video
      • Get Video for Mobile App/Custom Player
      • Update Video Image
      • Add Video Captions/Chapters/Subtitles
      • Delete Video Captions/Subtitles/Chapters
      • Create Expirable Links
      • Get Collected Emails
      • Setting Up Webhooks
      • Copy call-to-action (CTA) to Videos
      • Token Authentication
    • Projects
      • Create Project
      • Update a Project
      • Get Projects
      • Get a Project
      • Delete a Project
      • Set default CTA for Project
    • Live Streaming
      • Create a Live Stream
      • Update a Live Stream
      • Get Live Streams
      • Get a Live Stream
      • Count Live Streams
      • Live Streams Limit
      • Get Live Streaming Recording
      • Delete a Live Stream
      • Service and Regions for live streams
    • Channels
      • Get Channels
      • Get Channel
      • Delete Channel
    • Subscriptions
      • Create a Plan
      • Create a Member
      • Attach Plan To Member
      • Get Plans
      • Get Members
      • Get Member's Plans
      • Delete a Plan
    • Analytics
      • Use your User Ids in Analytics
      • Get Video Analytics
    • Javascript Events Methods
      • Plain Javascript Events & Methods
      • Control the Player using React
      • Control the Player in Vue.js
    • Developer Resources
      • How to embed DynTube player in Next.Js
      • How to embed the video player in React
      • How to play DynTube videos in React Native
      • ExoPlayer app to play HLS videos
      • How to embed videos & channels dynamically
      • How to Import Vimeo Videos into DynTube
Powered by GitBook
On this page
  • API URL
  • Post the image file using HTML From
  • To upload an image
  • Upload a File By URL
  • To upload a video
  • C# Sample
  • Node.js Sample
  • Python Sample
  • PHP Sample
  1. Reference
  2. Videos

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.";
}
PreviousGet Video for Mobile App/Custom PlayerNextAdd Video Captions/Chapters/Subtitles

Last updated 2 years ago