pip install vod-python-sdk
$ cd vod-python-sdk$ python setup.py install
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:# 处理业务异常print(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:# 处理业务异常print(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.Procedure = "Your Procedure Name"try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# 处理业务异常print(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:# 处理业务异常print(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.StorageRegion = "ap-chongqing"try:response = client.upload("ap-guangzhou", request)print(response.FileId)print(response.MediaUrl)except Exception as err:# 处理业务异常print(err)
ConcurrentUploadNumber
参数进行指定。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:# 处理业务异常print(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:# 处理业务异常print(err)
../
)。在调用 SDK 上传接口时,MediaFilePath
参数填写 manifest 路径,SDK 会解析出相关的媒体文件列表一并上传。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:# 处理业务异常print(err)
VodUploadClient
:属性名称 | 属性描述 | 类型 | 必填 |
secretId | 云 API 密钥 ID。 | String | 是 |
secretKey | 云 API 密钥 Key。 | String | 是 |
VodUploadRequest
:属性名称 | 属性描述 | 类型 | 必填 |
MediaFilePath | 待上传的媒体文件路径。必须为本地路径,不支持 URL。 | String | 是 |
SubAppId | Integer | 否 | |
MediaType | String | 否 | |
MediaName | 上传后的媒体名称,若不填默认采用 MediaFilePath 的文件名。 | String | 否 |
CoverFilePath | 待上传的封面文件路径。必须为本地路径,不支持 URL。 | String | 否 |
CoverType | String | 否 | |
Procedure | String | 否 | |
ExpireTime | String | 否 | |
ClassId | Integer | 否 | |
SourceContext | 来源上下文,用于透传用户请求信息,上传回调接口将返回该字段值,最长250个字符。 | String | 否 |
StorageRegion | String | 否 | |
ConcurrentUploadNumber | 分片并发数,针对大文件分片时有效。 | Integer | 否 |
VodUploadResponse
属性名称 | 属性描述 | 类型 |
FileId | 媒体文件的唯一标识。 | String |
MediaUrl | 媒体播放地址。 | String |
CoverUrl | 媒体封面地址。 | String |
RequestId | 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 | String |
VodUploadClient.upload(String region, VodUploadRequest request)
参数名称 | 参数描述 | 类型 | 必填 |
region | String | 是 | |
request | 上传请求。 | VodUploadRequest | 是 |
状态码 | 含义 |
InternalError | 内部错误。 |
InvalidParameter.ExpireTime | 参数值错误:过期时间。 |
InvalidParameterValue.CoverType | 参数值错误:封面类型。 |
InvalidParameterValue.MediaType | 参数值错误:媒体类型。 |
InvalidParameterValue.SubAppId | 参数值错误:子应用 ID。 |
InvalidParameterValue.VodSessionKey | 参数值错误:点播会话。 |
ResourceNotFound | 资源不存在。 |
本页内容是否解决了您的问题?