Generate a URL and Upload a Video

Learn how to upload and publish a video using Dailymotion API.

In this lesson, we'll learn about one of the most important services, video uploading, provided by Dailymotion. Video uploading and sharing are integral parts of any video creating and sharing platform. The video uploading process utilizes endpoints from the file and video objects. Uploading a video to Dailymotion is a five-step process as shown in the workflow diagram below:

Press + to interact
Workflow of uploading and publishing a video
Workflow of uploading and publishing a video

Authenticate user

Since we generated an access token in the previous lesson, therefore, we are already the authenticated user. Your access token must have manage_videos scope to work with the video uploading functionality.

Generate an upload URL

In this step, we'll make a GET request to the https://api.dailymotion.com/file/upload endpoint, and it returns upload_url and progress_url. The upload_url is extracted from the response, and we save it to use in the next section(s).

Request parameters

This endpoint does not take any parameter. Let’s see the functionality of this endpoint in the code widget below. ...

Press + to interact
Please provide values for the following:
ACCESS_TOKEN
Not Specified...
// Importing libraries here
const fetch = require("node-fetch");
// Define API key here
const API_KEY = 'Bearer {{ACCESS_TOKEN}}';
// Define endpoint URL here
const endpointUrl = 'https://api.dailymotion.com/file/upload';
// Define Header Parameters here
const headerParameters = {
authorization: API_KEY,
"Content-Type": "application/json",
};
// Setting API call options
const options = {
method: "GET",
headers: headerParameters,
};
// Function to make API call
async function generateUploadURL() {
try {
const response = await fetch(`${endpointUrl}`, options);
// Printing response
printResponse(response);
} catch (error) {
// Printing error message
printError(response);
}
}
// Calling function to make API call
generateUploadURL();

Let’s look at the highlighted lines in the code widget shown above: ...