...
/Generate a URL and Upload a Video
Generate a URL and Upload a Video
Learn how to upload and publish a video using Dailymotion API.
We'll cover the following...
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:
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. ...
// Importing libraries hereconst fetch = require("node-fetch");// Define API key hereconst API_KEY = 'Bearer {{ACCESS_TOKEN}}';// Define endpoint URL hereconst endpointUrl = 'https://api.dailymotion.com/file/upload';// Define Header Parameters hereconst headerParameters = {authorization: API_KEY,"Content-Type": "application/json",};// Setting API call optionsconst options = {method: "GET",headers: headerParameters,};// Function to make API callasync function generateUploadURL() {try {const response = await fetch(`${endpointUrl}`, options);// Printing responseprintResponse(response);} catch (error) {// Printing error messageprintError(response);}}// Calling function to make API callgenerateUploadURL();
Let’s look at the highlighted lines in the code widget shown above: ...