Post the image file using HTML From
If you have a remote URL of a file, you can provide the URL to upload your video to DynTube.
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}");
}
}
}
}
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}`);
});
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
$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.";
}