//*******************************简单使用***************************************************************
/**
 * 查看完整用法中的 "putObjectByRawApis"函数,查看使用基础的分片上传api进行文件上传,用户可以基于这个自行实现断点续传等功能
 */
// 使用分片上传接口上传文件, 接口会根据文件大小决定是使用普通上传还是分片上传
$ossClient->multiuploadFile($bucket, "file.php", __FILE__, array());
Common::println("local file " . __FILE__ . " is uploaded to the bucket {$bucket}, file.php");
// 上传本地目录到bucket内的targetdir子目录中
$ossClient->uploadDir($bucket, "targetdir", __DIR__);
Common::println("local dir " . __DIR__ . " is uploaded to the bucket {$bucket}, targetdir/");
// 列出当前未完成的分片上传
$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array());
//******************************* 完整用法参考下面函数 ****************************************************
multiuploadFile($ossClient, $bucket);
putObjectByRawApis($ossClient, $bucket);
uploadDir($ossClient, $bucket);
listMultipartUploads($ossClient, $bucket);
/**
 * 通过multipart上传文件
 *
 * @param OssClient $ossClient OssClient实例
 * @param string $bucket 存储空间名称
 * @return null
 */
function multiuploadFile($ossClient, $bucket)
{
    $object = "test/multipart-test.txt";
    $file = __FILE__;
    $options = array();
    try {
        $ossClient->multiuploadFile($bucket, $object, $file, $options);
Beispiel #2
0
    $object_name = 'object name';
    $options = null;
    $response = $client->get_object_meta($bucket_name, $object_name, $options);
}
//下载对象
function my_download_object()
{
    $bucket_name = 'download bucket';
    $object_name = 'download object';
    $options = array(ALIOSS::OSS_FILE_DOWNLOAD => "download path", ALIOSS::OSS_RANGE => '0-1');
    $response = $client > get_object($bucket_name, $object_name, $options);
}
$a = $_GET['a'];
switch ($a) {
    case 1:
        uploadDir($oss, $bucket);
        break;
    case 2:
        fenduan($oss, $object, $bucket, $upload_file);
        break;
    case 3:
        get_obj_list($oss, $bucket, $options);
        break;
    case 4:
        create_obj($oss, $bucket);
        break;
    case 5:
        ajax_upload($oss, $bucket);
        break;
    case 6:
        ajax_response();