dotnet add package VodSDK --version 1.0.1
VodUploadClient
instance with a TencentCloud API key.using System;using VodSDK;VodUploadClient client = new VodUploadClient("your secretId", "your secretKey");
VodUploadRequest request = new VodUploadRequest();request.MediaFilePath = "/data/videos/Wildlife.wmv";
try{VodUploadResponse response = client.Upload("ap-guangzhou", request);// Print the media FileIdConsole.WriteLine(response.FileId);}catch (Exception e){// The business team performs troubleshootingConsole.WriteLine(e);}
using System;using VodSDK;VodUploadClient client = new VodUploadClient("your secretId", "your secretKey");VodUploadRequest request = new VodUploadRequest();request.MediaFilePath = "/data/videos/Wildlife.wmv";request.CoverFilePath = "/data/videos/Wildlife.jpg";try{VodUploadResponse response = client.Upload("ap-guangzhou", request);// Print the media FileIdConsole.WriteLine(response.FileId);}catch (Exception e){// The business team performs troubleshootingConsole.WriteLine(e);}
Procedure
parameter with the task flow template name, and the task flow will be executed automatically upon upload success.using System;using VodSDK;VodUploadClient client = new VodUploadClient("your secretId", "your secretKey");VodUploadRequest request = new VodUploadRequest();request.MediaFilePath = "/data/videos/Wildlife.wmv";request.Procedure = "Your Procedure Name";try{VodUploadResponse response = client.Upload("ap-guangzhou", request);// Print the media FileIdConsole.WriteLine(response.FileId);}catch (Exception e){// The business team performs troubleshootingConsole.WriteLine(e);}
using System;using VodSDK;VodUploadClient client = new VodUploadClient("your secretId", "your secretKey");VodUploadRequest request = new VodUploadRequest();request.MediaFilePath = "/data/videos/Wildlife.wmv";request.SubAppId = 101;try{VodUploadResponse response = client.Upload("ap-guangzhou", request);// Print the media FileIdConsole.WriteLine(response.FileId);}catch (Exception e){// The business team performs troubleshootingConsole.WriteLine(e);}
StorageRegion
attribute.using System;using VodSDK;VodUploadClient client = new VodUploadClient("your secretId", "your secretKey");VodUploadRequest request = new VodUploadRequest();request.MediaFilePath = "/data/videos/Wildlife.wmv";request.StorageRegion = "ap-chongqing";try{VodUploadResponse response = client.Upload("ap-guangzhou", request);// Print the media FileIdConsole.WriteLine(response.FileId);}catch (Exception e){// The business team performs troubleshootingConsole.WriteLine(e);}
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 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 subapp 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 Video Upload Overview. 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 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 Video Upload Overview. If the CoverFilePath path contains a file extension, this parameter can be left empty. | String | No |
Procedure | Name of the task flow to be automatically executed after upload is completed. This parameter is specified when the task flow is created through the API or console. For more information, please see Task Flow Overview. | String | No |
ExpireTime | Expiration time of the media file in ISO 8601 format. For more information, please 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 CreateClass. | 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 cover 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 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: Subapplicationp ID. |
InvalidParameterValue.VodSessionKey | Incorrect parameter value: VOD session. |
ResourceNotFound | The resource does not exist. |
Was this page helpful?