{"require": {"qcloud/vod-sdk-v5": "v2.4.0"}}
autoload.php
file.VodUploadClient
instance with a TencentCloud API key.<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;$client = new VodUploadClient("your secretId", "your secretKey");
<?phprequire 'vod-sdk-v5/autoload.php';use Vod\\VodUploadClient;$client = new VodUploadClient("your secretId", "your secretKey");
use Vod\\Model\\VodUploadRequest;$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/Wildlife.wmv";
try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;use Vod\\Model\\VodUploadRequest;$client = new VodUploadClient("your secretId", "your secretKey");$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/Wildlife.wmv";$req->CoverFilePath = "/data/videos/Wildlife-Cover.png";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";echo "CoverUrl -> ". $rsp->CoverUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
Procedure
parameter with the task flow template name, and the task flow will be executed automatically upon upload success.<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;use Vod\\Model\\VodUploadRequest;$client = new VodUploadClient("your secretId", "your secretKey");$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/Wildlife.wmv";$req->Procedure = "Your Procedure Name";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;use Vod\\Model\\VodUploadRequest;$client = new VodUploadClient("your secretId", "your secretKey");$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/Wildlife.wmv";$req->SubAppId = 101;try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
StorageRegion
attribute.<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;use Vod\\Model\\VodUploadRequest;$client = new VodUploadClient("your secretId", "your secretKey");$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/Wildlife.wmv";$req->StorageRegion = "ap-chongqing";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;use Vod\\Model\\VodUploadRequest;$client = new VodUploadClient("Credentials TmpSecretId", "Credentials TmpSecretKey", "Credentials Token");$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/Wildlife.wmv";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;use Vod\\Model\\VodUploadRequest;use Vod\\Model\\VodUploadHttpProfile;$client = new VodUploadClient("your secretId", "your secretKey");$uploadHttpProfile = new VodUploadHttpProfile("your proxy addr");$client->setHttpProfile($uploadHttpProfile);$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/Wildlife.wmv";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
manifest
(M3U8 or MPD) must be relative paths (i.e., URLs and absolute paths cannot be used) and be located in the same-level directory or subdirectory of manifest
(i.e., ../
cannot be used). When calling the SDK's upload APIs, enter the manifest
path as the MediaFilePath
parameter, and the SDK will parse the list of related media files and upload them together.<?phprequire 'vendor/autoload.php';use Vod\\VodUploadClient;use Vod\\Model\\VodUploadRequest;$client = new VodUploadClient("your secretId", "your secretKey");$req = new VodUploadRequest();$req->MediaFilePath = "/data/videos/prog_index.m3u8";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// Handle upload exceptionecho $e;}
VodUploadClient
Attribute Name | Attribute Description | Type | Required |
secretId | The ID of TencentCloud API key | String | Yes |
secretKey | TencentCloud API key | String | Yes |
VodUploadRequest
Attribute Name | Attribute Description | Type | Required |
MediaFilePath | Path to the media file to be uploaded, which must be a local path and does not support URLs. | String | Yes |
SubAppId | ID of a subapplication in VOD. If you need to access a resource in a subapplication, enter the subapplication ID in this field; otherwise, leave it empty. | Integer | No |
MediaType | Type of the media file to be uploaded. For the valid values, see Overview of media upload. If the MediaFilePath path contains a file extension, this parameter can be left empty. | String | No |
MediaName | Name of the media file after being uploaded. If this parameter is left empty, the filename in MediaFilePath will be used by default. | String | No |
CoverFilePath | Path to the thumbnail file to be uploaded, which must be a local path and does not support URLs. | String | No |
CoverType | Type of the thumbnail file to be uploaded. For the valid values, see Overview of media upload. If the CoverFilePath path contains a file extension, this parameter can be left empty. | String | No |
Procedure | String | No | |
ExpireTime | Expiration time of media file in ISO 8601 format. For more information, see notes on ISO date format. | String | No |
ClassId | Category ID, which is used to categorize the media for management. A category can be created and its ID can be obtained by using the category creating API. | Integer | No |
SourceContext | Source context of up to 250 characters, which is used to pass through the user request information and will be returned by the upload callback API. | String | No |
StorageRegion | Storage region, which specifies the region where to store the file. This field should be filled in with a region abbreviation. | String | No |
VodUploadResponse
Attribute Name | Attribute Description | Type |
FileId | Unique ID of the media file. | String |
MediaUrl | Media playback address. | String |
CoverUrl | Media thumbnail address. | String |
RequestId | Unique ID of the request. Each request returns a unique ID. The RequestId is required to troubleshoot issues. | String |
VodUploadClient.upload(String region, VodUploadRequest request)
Parameter | Description | Type | Required |
region | Access point region, i.e., the region where to request a VOD server. This is different from the storage region. For more information, see the list of supported regions. | String | Yes |
request | Upload request. | VodUploadRequest | Yes |
Status Code | Description |
InternalError | Internal error. |
InvalidParameter.ExpireTime | Incorrect parameter value: Expiration time. |
InvalidParameterValue.CoverType | Incorrect parameter value: Thumbnail type. |
InvalidParameterValue.MediaType | Incorrect parameter value: Media type. |
InvalidParameterValue.SubAppId | Incorrect parameter value: Subapplication ID. |
InvalidParameterValue.VodSessionKey | Incorrect parameter value: VOD session. |
ResourceNotFound | Resource does not exist. |
Was this page helpful?