{"require": {"qcloud/vod-sdk-v5": "v2.4.0"}}
<?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) {// 处理上传异常echo $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) {// 处理上传异常echo $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->Procedure = "Your Procedure Name";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// 处理上传异常echo $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) {// 处理上传异常echo $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->StorageRegion = "ap-chongqing";try {$rsp = $client->upload("ap-guangzhou", $req);echo "FileId -> ". $rsp->FileId . "\\n";echo "MediaUrl -> ". $rsp->MediaUrl . "\\n";} catch (Exception $e) {// 处理上传异常echo $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) {// 处理上传异常echo $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) {// 处理上传异常echo $e;}
../
)。在调用 SDK 上传接口时,MediaFilePath
参数填写 manifest 路径,SDK 会解析出相关的媒体文件列表一并上传。<?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) {// 处理上传异常echo $e;}
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 | 否 |
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 | 资源不存在。 |
本页内容是否解决了您的问题?