Skip to main content

How to upload videos

This detailed guide outlines the two primary methods for uploading videos to the Teyuto platform: uploading from a local file and uploading from an origin URL.

Overview of Upload Methods

  1. Local File Upload: Uses the TUS protocol to upload video files directly from your device.
  2. Origin URL Upload: Provides the URL of an already hosted video for Teyuto to fetch.

1. Local File Upload

This method is ideal for videos stored on your device. It utilizes the TUS protocol, optimized for large file uploads.

Step 1: Create a Video Entity

Before initiating the upload, you must create a video entity in the Teyuto system.

  1. Make a POST request to the Teyuto API
  2. Include necessary video details (title, description, etc.) in the request body.

Example using cURL:

curl -X POST https://api.teyuto.com/v2/videos \
-H "Content-Type: application/json" \
-H "Authorization: YOUR_API_TOKEN" \
-d '{"title": "My Video Title"}'
  1. Receive the created video's ID in the response.

Step 2: Obtain TUS Parameters

After creating the video entity, get the parameters for the TUS upload session.

  1. Send a GET request to: https://api.teyuto.tv/v2/videos/{idVideo}/signed/upload Example using cURL:
curl -X GET https://api.teyuto.com/v2/videos/{idVideo}/signed/upload \
-H "Content-Type: application/json" \
-H "Authorization: YOUR_API_TOKEN" \

Replace {idVideo} with the ID received in Step 1.

  1. This request returns:
    • Hostname for the upload server
    • Secure token
    • Client ID
    • Video ID

Step 3: Upload Using TUS Client

Use a TUS client library to perform the actual file upload.

Important

TUS Client supports: JavaScript, Python, Java, .NET, PHP, Go, Ruby, Rust, iOS, Android, React Native, Flutter, CLI

  1. Choose a TUS client for your platform from tus.io/implementations.
  2. Construct the upload endpoint: https://{hostname}/upload/
  3. Implement the upload using the chosen TUS client. Here's a JavaScript example:
<script src="https://cdn.jsdelivr.net/npm/tus-js-client@latest/dist/tus.min.js"></script>

<script>
// Assume 'data' contains the response from Step 2 and 'file' is your video file
uploads[data.video.id] = new tus.Upload(file, {
endpoint: `https://${data.hostname}/upload/`,
autoRetry: true,
retryDelays: [0, 3000, 5000, 10000, 20000],
chunkSize: 10000000, // 10MB chunks, mandatory for files over 10GB
metadata: {
filename: data.video_name,
token: data.token,
video_id: data.video_id,
client_id: data.client_id
},
onSuccess: function() {
console.log("Upload completed successfully");
}
});

uploads[data.video.id].start();
</script>

2. Origin URL Upload

This method is simpler but requires your video to be accessible via a public URL.

Step 1: Prepare API Call

You'll make a POST request to the Teyuto API to initiate the upload.

Endpoint: https://api.teyuto.com/v2/videos

Step 2: Make API Call

Send a POST request with these required parameters:

  • title: Your video's title
  • origin_url: The full URL of the MP4 file

Example using cURL:

curl -X POST https://api.teyuto.com/v2/videos \
-H "Content-Type: application/json" \
-H "Authorization: YOUR_API_TOKEN" \
-d '{"title": "My Video Title", "origin_url": "https://example.com/path/to/video.mp4"}'

Replace YOUR_API_TOKEN with your actual Teyuto API token.

Monitoring Upload Status

Regardless of the upload method, you can check your video's status:

  1. API Method:

    • Send a GET request to https://api.teyuto.com/v2/videos/{id}/status

    Replace {id} with your video's ID

    curl -X GET https://api.teyuto.com/v2/videos/{idVideo}/status \
    -H "Content-Type: application/json" \
    -H "Authorization: YOUR_API_TOKEN" \
    • The response includes a status field indicating the video's current state
  2. Dashboard Method:

    • Log into your Teyuto account
    • Navigate to the Videos section
    • View the status of all uploaded videos, including those in progress

Conclusion

Teyuto offers two flexible methods for uploading videos:

  1. Local file upload using TUS protocol, ideal for videos on your device.
  2. Origin URL upload, perfect for videos already hosted online.

Both methods allow for status monitoring via API or dashboard. Choose the method that best suits your needs and existing video storage setup. Always handle potential errors during the upload process and provide appropriate user feedback.

For more detailed information, consult the official Teyuto API documentation and TUS protocol specifications.