3

我想让我的用户可以使用临时 url 和 HTML POST 表单将文件直接上传到 OpenStack 上的云。
在 openstack 文档中,他们有: Upload objects directly to the Object Storage system from a browser by using form POST middleware
但我不知道如何构建正确的 HTML 表单?任何人有一个例子如何在PHP中做到这一点?在我的代码下面:

$client = new OpenStack('https://auth.cloud.ovh.net/v2.0/', array(
        'username' => 'xxxxx',
        'password' => 'xxxxx',
        'tenantId' => 'xxxxx'
    ));

    $objectStoreService = $client->objectStoreService('swift', 'SBG1');

    $container = $objectStoreService->getContainer("XXXXX");
    $object = $container->dataObject();
    $object->setName("test");

    $expire = 60*10;
    $tempUrl = $object->getTemporaryUrl($expire, "PUT");

    return $this->render("CloudUpload:Main:index.html.twig", array("url" => $tempUrl));

来自Rackspace github的 OpenStack 类

    {% block body %}
<form method="POST" action="{{ url }}" enctype="multipart/form-data">
    <input type="file" name="file">
    <button name="submit" type="submit">Send</button>
</form>
    {% endblock %}

如果我发送此请求,来自云端的响应是:

400 Bad Request
FormPost:超过最大文件数

编辑:也许用这些数据创建 AJAX 请求将是解决方案?

4

0 回答 0