-
Notifications
You must be signed in to change notification settings - Fork 977
Upload videos from third party applications
This tutorial provides step-by-step instructions for third-party applications to upload files to AVideo, ensuring secure authentication and detailed video metadata submission.
To interact with AVideo's API, you'll need to use an encrypted password. This is how you can obtain it:
Each AVideo installation comes with a script to encode passwords. It can vary, especially if the installation uses a salt for enhanced security. Typically, you would access it like so:
https://yourSite/objects/encryptPass.json.php?pass=YOUR_PASSWORD
Replace yourSite
with your AVideo installation URL and YOUR_PASSWORD
with the actual password you wish to encrypt.
Navigate to the URL from step 1. This will return your encrypted password in JSON format. For example, using a browser or a tool like curl
:
curl https://yourSite/objects/encryptPass.json.php?pass=123
This request returns an encrypted password that looks like this:
{"encryptedPassword":"ENCRYPTED_PASSWORD_HERE"}
To upload files, use the Mobile Plugin Upload File endpoint. Here’s how:
Your URL will include your username and the encrypted password obtained previously:
yourSite/plugin/MobileManager/upload.php?user=USERNAME&pass=ENCRYPTED_PASSWORD
Replace yourSite
with your AVideo site URL, USERNAME
with your actual username, and ENCRYPTED_PASSWORD
with the encrypted password you received.
Here’s an example of a curl
command to upload the file:
curl -X POST \
-F "upl=@/path/to/your/video.mp4" \
-F "title=Your Video Title" \
-F "description=A brief description of the video" \
-F "categories_id=1" \
-F "can_share=1" \
-F "video_password=YourVideoPassword" \
"https://yourSite/plugin/MobileManager/upload.php?user=USERNAME&pass=ENCRYPTED_PASSWORD"
-
-X POST
: Specifies that the request is a POST request. -
-F
: Sends form data.-
upl=@/path/to/your/video.mp4
: Replace/path/to/your/video.mp4
with the full path to your video file. -
title=Your Video Title
: ReplaceYour Video Title
with the desired title of the video. -
description=A brief description of the video
: ReplaceA brief description of the video
with your video description. -
categories_id=1
: Replace1
with the category ID for the video. -
can_share=1
: Set to1
if the video can be shared; otherwise, omit this field or set it to0
. -
video_password=YourVideoPassword
: If the video requires a password, include it here; otherwise, omit this field.
-
You can also use an HTML form to submit files and metadata. Below is a sample form:
<form enctype="multipart/form-data" method="post" action="https://yourSite/plugin/MobileManager/upload.php?user=USERNAME&pass=ENCRYPTED_PASSWORD">
<input name="title" type="text" placeholder="Video Title" /><br>
<input name="description" type="text" placeholder="Video Description" /><br>
<input name="categories_id" type="text" placeholder="Category ID" /><br>
<input name="can_share" type="checkbox" value="1" /> Can Share<br>
<input name="video_password" type="password" placeholder="Video Password" /><br>
<input name="upl" type="file" accept="video/*" /><br>
<input type="submit" value="Upload Video" />
</form>
Replace https://yourSite
with your AVideo site URL, USERNAME
with your username, and ENCRYPTED_PASSWORD
with your encrypted password.
Below is an example of how to upload a file using PHP:
<?php
// Configuration
$uploadUrl = "https://yourSite/plugin/MobileManager/upload.php";
$username = "USERNAME";
$encryptedPassword = "ENCRYPTED_PASSWORD";
// File and Metadata
$filePath = "/path/to/your/video.mp4"; // Full path to the video file
title = "Your Video Title";
description = "A brief description of the video";
categoriesId = 1; // Category ID
canShare = 1; // Set to 1 for sharing; 0 otherwise
videoPassword = "YourVideoPassword";
// Build the full URL with credentials
$uploadUrl .= "?user=" . urlencode($username) . "&pass=" . urlencode($encryptedPassword);
// Prepare the POST data
$postData = [
'upl' => new CURLFile($filePath, mime_content_type($filePath), basename($filePath)),
'title' => $title,
'description' => $description,
'categories_id' => $categoriesId,
'can_share' => $canShare,
'video_password' => $videoPassword,
];
// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uploadUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the request
$response = curl_exec($ch);
// Check for errors
if ($response === false) {
die('Upload failed: ' . curl_error($ch));
}
// Close cURL
curl_close($ch);
// Output the response
echo "Server Response: " . $response;
?>
You can send additional metadata for the video using either GET or POST parameters:
-
title
: The title of the video. -
description
: A brief description of the video. -
categories_id
: The ID for the video category. -
can_share
: Set this to1
to allow sharing of the video. -
video_password
: If you wish to protect the video with a password.
AVideo supports webhooks through the Notifications Plugin for events like new video uploads. For setup and more details, refer to the [Notifications Plugin documentation]
Ensure the LimitRequestBody
directive in your server configuration allows uploads of large files. This directive sets the maximum size of the request body (in bytes) allowed by the server. If it is set too low, uploads will fail.
-
Default Value: The default value for
LimitRequestBody
is 1 GB if it is not set or is set to0
. - Recommended Value for AVideo: Set this directive to a minimum of 5 GB. For enhanced performance and larger uploads, consider setting it to 10 GB, as used in many high-performance servers.
To update this setting:
- Locate your Apache configuration file. This is typically
httpd.conf
or included files (e.g.,/etc/apache2/apache2.conf
or.htaccess
). - Open the file for editing. For example:
sudo nano /etc/apache2/apache2.conf
- Add or update the directive:
LimitRequestBody 10737418240 # 10 GB
-
Save and exit the file (
CTRL+O
, thenCTRL+X
). -
Restart your Apache server to apply the changes:
sudo systemctl restart apache2
Ensure the PHP configuration allows for large file uploads. Update the following parameters in the PHP configuration file (php.ini
):
- Open the
php.ini
file for editing:
sudo nano /etc/php/7.4/apache2/php.ini
Replace 7.4
with your PHP version if different.
- Locate and modify the following parameters:
upload_max_filesize = 5G
post_max_size = 5G
-
Save and exit the file (
CTRL+O
, thenCTRL+X
). -
Restart Apache to apply the changes:
sudo systemctl restart apache2
Ensure these settings match the intended maximum upload size for your application.