我想让我的用户可以使用临时网址和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));
的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请求会有解决方案吗?