Videos
Update Video Image
Upload a new thumbnail image for an existing video.
API URL
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | String | Bearer YOUR_API_KEY |
Post the image file using HTML Form
- The file can be added to a 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 |
200: OK
json
{
"ok": true,
"error": null,
"image": null
}Upload an Image By URL
If the image is already available at a direct remote URL, provide that URL to update the DynTube video thumbnail.
- The process is the same as uploading a normal file but instead of providing a file input, you can provide a field named url
- Submit the multipart form to the following endpoint.
- The Content-Type should be multipart/form-data.
To upload an image by URL
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. |
200: OK
C# Sample
csharp
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
javascript
const fs = require('fs');
const axios = require('axios');
const FormData = require('form-data');
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 formData = new FormData();
formData.append('file', fs.createReadStream(filePath), 'image.png');
axios.put(url, formData, {
headers: {
Authorization: `Bearer ${bearerToken}`,
...formData.getHeaders()
}
})
.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
python
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}";
$ch = curl_init($url);
$data = array(
'file' => new CURLFile($filePath)
);
curl_setopt_array($ch, array(
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array("Authorization: Bearer {$bearerToken}"),
CURLOPT_RETURNTRANSFER => true
));
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 200 && $status < 300) {
echo "Video image updated successfully.";
} else {
echo "Error updating video image. Status code: {$status}";
}Related Pages
- Get video to inspect the current thumbnail and image fields.
- Update video to change metadata or player options.
- Get videos to list videos and confirm the thumbnail update.
Something missing or wrong here? Tell us and we will correct it. New to DynTube? Start with uploading and embedding.