Softlayer PHP 客户端中的分块文件上传

Chunked file uploads in Softlayer PHP Client

我需要将大文件上传到 Softlayer 对象存储。如何使用 PHP 对象存储客户端执行此操作?

这里有一个 php 使用 SoftLayer Object Storage PHP Client:

上传文件的例子
<?php
require_once ('lib/ObjectStorage/Util.php');

class ObjectStorageSL{

    var $objectStorage;
    public function __construct($host, $username, $password, $options) {

        $this -> objectStorage = new ObjectStorage($host, $username, $password, $options);

    }

    /**
     * This method shows token and url from an object storage
     * @var $objectStorage - Object Storage connection
     */
    function displayTokenUrl() {
        print("Token: " . $this -> objectStorage -> getAuthenticationData() -> authToken . "\n");
        print("Url: " . $this -> objectStorage -> getAuthenticationData() -> objectStorageUrl);
    }

    /**
     * This method uploads a file located in your local machine
     * @var $objectStorage - Object Storage connection
     * @var $containerName - The container's name where you want to upload the object
     * @var $objectName - The object's name that you wish to assign for the file uploaded
     * @var $path - The path where the file is located
     */
    function uploadFile($containerName, $objectName, $path) {
        try {
            $result = $this -> objectStorage -> with($containerName . "/" . $objectName) -> setLocalFile($path) -> create();
            print("\n".$result -> getUrl());
            print("\nThe file has been uploaded");
        } catch(Exception $e) {
            echo "\nError: " . $e -> getMessage();
        }
    }
}


/**
 * Declare Object Storage parameters
 */
$host = 'https://mil01.objectstorage.softlayer.net/auth/v1.0/';
// Declare your username and password for Object Storage connection
$username = 'set me';
$password = 'set me';
$options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);

/**
 * Create Object Storage Connection
 */
$objectStorage = new ObjectStorageSL($host, $username, $password, $options);

/**
 * Display Token and Url
 */
$objectStorage -> displayTokenUrl();
$path = "C:\Project\task.xml";
$objectStorage -> uploadFile("rcvTest", "task1.xml", $path);

我没有用大于 10 MB 的文件对其进行测试,但它应该可以工作,如果您遇到问题或有任何问题,请告诉我