pip install vod-python-sdk
$ cd vod-python-sdk$ python setup.py install
VodUploadClient
instance with a TencentCloud API key.from qcloud_vod.vod_upload_client import VodUploadClientclient = VodUploadClient("your secretId", "your secretKey")
from qcloud_vod.model import VodUploadRequestrequest = VodUploadRequest()request.MediaFilePath = "/data/file/Wildlife.mp4"
try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# Handle business exceptionprint(err)
from qcloud_vod.vod_upload_client import VodUploadClientfrom qcloud_vod.model import VodUploadRequestclient = VodUploadClient("your secretId", "your secretKey")request = VodUploadRequest()request.MediaFilePath = "/data/file/Wildlife.mp4"request.CoverFilePath = "/data/file/Wildlife-Cover.png"try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)print(response.CoverUrl)except Exception as err:# Handle business exceptionprint(err)
Procedure
parameter with the task flow template name, and the task flow will be executed automatically upon upload success.from qcloud_vod.vod_upload_client import VodUploadClientfrom qcloud_vod.model import VodUploadRequestclient = VodUploadClient("your secretId", "your secretKey")request = VodUploadRequest()request.MediaFilePath = "/data/file/Wildlife.mp4"request.Procedure = "Your Procedure Name"try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# Handle business exceptionprint(err)
from qcloud_vod.vod_upload_client import VodUploadClientfrom qcloud_vod.model import VodUploadRequestclient = VodUploadClient("your secretId", "your secretKey")request = VodUploadRequest()request.MediaFilePath = "/data/file/Wildlife.mp4"request.SubAppId = 101try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# Handle business exceptionprint(err)
StorageRegion
attribute.from qcloud_vod.vod_upload_client import VodUploadClientfrom qcloud_vod.model import VodUploadRequestclient = VodUploadClient("your secretId", "your secretKey")request = VodUploadRequest()request.MediaFilePath = "/data/file/Wildlife.mp4"request.StorageRegion = "ap-chongqing"try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# Handle business exceptionprint(err)
ConcurrentUploadNumber
parameter.from qcloud_vod.vod_upload_client import VodUploadClientfrom qcloud_vod.model import VodUploadRequestclient = VodUploadClient("your secretId", "your secretKey")request = VodUploadRequest()request.MediaFilePath = "/data/file/Wildlife.mp4"request.ConcurrentUploadNumber = 5try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# Handle business exceptionprint(err)
from qcloud_vod.vod_upload_client import VodUploadClientfrom qcloud_vod.model import VodUploadRequestclient = VodUploadClient("Credentials TmpSecretId", "Credentials TmpSecretKey", "Credentials Token")request = VodUploadRequest()request.MediaFilePath = "/data/file/Wildlife.mp4"try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# Handle business exceptionprint(err)
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.from qcloud_vod.vod_upload_client import VodUploadClientfrom qcloud_vod.model import VodUploadRequestclient = VodUploadClient("your secretId", "your secretKey")request = VodUploadRequest()request.MediaFilePath = "/data/file/prog_index.mp4"try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# Handle business exceptionprint(err)
VodUploadClient
:Attribute Name | Attribute Description | Type | Required |
secretId | TencentCloud API key ID. | String | Yes |
secretKey | TencentCloud API key. | String | Yes |
VodUploadRequest
:Attribute Name | Attribute Description | Type | Required |
MediaFilePath | Path of the media file to be uploaded, which must be a local path and does not support URLs. | String | Yes |
SubAppId | ID of 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, please 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 of the cover file to be uploaded, which must be a local path and does not support URLs. | String | No |
CoverType | Type of the cover file to be uploaded. For the valid values, please 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, please see the 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 CreateClass 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 |
ConcurrentUploadNumber | Number of concurrent parts, which is valid when a large file is uploaded in multiple parts. | Integer | No |
VodUploadResponse
Attribute Name | Attribute Description | Type |
FileId | Unique ID of media file. | String |
MediaUrl | Media playback address. | String |
CoverUrl | Media cover address. | String |
RequestId | Unique ID of request. Each request returns a unique ID. The RequestId is required to troubleshoot issues. | String |
VodUploadClient.upload(String region, VodUploadRequest request)
Parameter Name | 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, please 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: cover type. |
InvalidParameterValue.MediaType | Incorrect parameter value: media type. |
InvalidParameterValue.SubAppId | Incorrect parameter value: subapplication ID. |
InvalidParameterValue.VodSessionKey | Incorrect parameter value: VOD session. |
ResourceNotFound | The resource does not exist. |
Was this page helpful?