You need to enable JavaScript to run this app.
文档中心
文档控制台
注册
veImageX

veImageX

复制全文
下载 pdf
PHP SDK
资源管理
复制全文
下载 pdf
资源管理

阅读本文,您可以获取 PHP SDK 资源管理的接口调用示例,实现快速开发。

说明

本文的调用示例包含接口的部分参数。由于参数间可能存在互斥关系,在调用时,请您参考注释,进行调整。

调用说明

  • 本文提供的接口调用示例均通过 AK 和 SK 初始化实例。
  • 接口的参数说明和错误码等信息可通过接口文档文档说明页签查看。

前提条件

调用接口前,请先完成 PHP SDK 的安装及初始化操作。

调用示例

本节为您介绍资源管理相关接口的功能和调用示例。

普通上传

以下内容用于通过指定服务 ID 和上传文件,来获取上传成功的资源 URI。

UploadImages 接口内部依次调用了 ApplyImageUpload 和 CommitImageUpload 两个 OpenAPI 来实现完整文件上传能力。我们同时在 GitHub 上提供了参考示例

具体示例如下所示:

<?php
include_once(__DIR__ . '/../../vendor/autoload.php');

use Volc\Service\ImageX;

$client = ImageX::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$params = array();
$params["ServiceId"] = "imagex service id";
$filePaths = array("image path 1");

$response = $client->uploadImages($params, $filePaths);
print_r($response);

分片上传

对大于 20MB 的文件,您可以通过将文件数据分成多个分片(part)来同时分片上传,最后将所有上传的分片合并为一个文件并获取存储地址。分片上传最大能够上传 48.8TB 文件,其中除了最后一个分片,其他分片大小需大于等于 5MB 且小于 5GB。分片数量默认从 1 开始,最大为 10000。

说明

上传顺序不影响最终的合并分片操作。如果其中任意分片上传失败,可以重新进行上传且不影响其他分片。

删除服务下多个文件

您可以调用 DeleteImageUploadFiles 接口删除指定的文件。详细的参数说明可参见 DeleteImageUploadFiles 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$body = [];

$response = $client->deleteImageUploadFiles($query, $body);
print_r($response);

预览服务下的文件

您可以调用 PreviewImageUploadFile 接口获取指定文件的详细信息。详细的参数说明可参见 PreviewImageUploadFile 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$response = $client->previewImageUploadFile($query);
print_r($response);

列举服务下的文件

您可以调用 GetImageStorageFiles 接口列举并返回服务对应存储下的全量资源,并按照 Key 的字典序返回。详细的参数说明可参见 GetImageStorageFiles 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$response = $client->getImageStorageFiles($query);
print_r($response);

修改文件存储类型

您可以调用 UpdateFileStorageClass 接口修改文件存储类型。详细的参数说明可参见 UpdateFileStorageClass 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$body = [];

$response = $client->updateFileStorageClass($query, $body);
print_r($response);

更新资源封禁/解封状态

您可以调用 UpdateImageResourceStatus 接口修改指定服务下资源的封禁状态。详细的参数说明可参见 UpdateImageResourceStatus 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$body = [];

$response = $client->updateImageResourceStatus($query, $body);
print_r($response);

重命名文件

您可以调用 UpdateImageFileKey 接口通过指定源文件的 storekey 来对指定文件进行重命名操作。详细的参数说明可参见 UpdateImageFileKey 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$body = [];

$response = $client->updateImageFileKey($query, $body);
print_r($response);

恢复文件

您可以调用 CreateFileRestore 接口恢复文件。详细的参数说明可参见 CreateFileRestore 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$body = [];

$response = $client->createFileRestore($query, $body);
print_r($response);

获取服务下单个上传文件

您可以调用 GetImageUploadFile 接口指定服务 ID 以及已上传的文件 Uri,来获取上传文件的详细信息。详细的参数说明可参见 GetImageUploadFile 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$response = $client->getImageUploadFile($query);
print_r($response);

获取服务下的上传文件列表

您可以调用 GetImageUploadFiles 接口获取当前服务下全部的上传文件信息。详细的参数说明可参见 GetImageUploadFiles 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$response = $client->getImageUploadFiles($query);
print_r($response);

更新文件的 Content-Type 值

您可以调用 UpdateImageFileCT 接口更新文件的 Content-Type 值。详细的参数说明可参见 UpdateImageFileCT 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$body = [];

$response = $client->updateImageFileCT($query, $body);
print_r($response);

获取资 URL

您可以调用 GetResourceURL 接口获取指定服务即域名的资源地址。详细的参数说明可参见 GetResourceURL 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$response = $client->getResourceURL($query);
print_r($response);

复制资源

您可以调用 CreateImageFromUri 接口源服务内的存储资源,复制到目标服务中。详细的参数说明可参见 CreateImageFromUri 接口文档。

接口调用示例如下所示。

<?php
include_once(__DIR__ . '/../../../../vendor/autoload.php');

use Volc\Service\ImageX\V2\Imagex;

$client = Imagex::getInstance();

// call below method if you dont set ak and sk in ~/.volc/config
$client->setAccessKey("ak");
$client->setSecretKey("sk");

$query = [];

$body = [];

$response = $client->createImageFromUri($query, $body);
print_r($response);
最近更新时间:2024.12.05 18:30:54
这个页面对您有帮助吗?
有用
有用
无用
无用