3

I want to give my users possibility to upload files directly to my cloud on OpenStack using temp url's and HTML POST form.
In openstack docs they have: Upload objects directly to the Object Storage system from a browser by using form POST middleware
But i don't know how to build correct HTML form? Any one have a example how to do it in PHP? Below my code:

$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 class from Rackspace github

    {% 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 %}

Response from cloud if I send this request is:

400 Bad Request
FormPost: Max File Count Exceeded

edit: Maybe create AJAX request with this data will be solution?

Przemek
  • 31
  • 4
  • 1
    Have you found a solution for this yet ? – Mecanik May 12 '18 at 08:26
  • 1
    @NorbertBoros Yes. I found solution. I can upload code on Github if you want, but I would need some time. Maybe tomorrow? – Przemek May 13 '18 at 22:29
  • 1
    yes that would be great, thanks! – Mecanik May 14 '18 at 05:13
  • @NorbertBoros I don't know if you have notifications about my response but lower as answer you have link to my GH where u find working sample. I hope this will help you :) – Przemek May 15 '18 at 02:41
  • Unfortunately, I cannot see any link to your github... – Mecanik May 15 '18 at 13:15
  • 1
    @NorbertBoros Yes because one of mods deleted my answer. But lets try in comment :) https://github.com/przemek3697/OpenStackPostUpload – Przemek May 16 '18 at 01:55
  • Super mods... what can I say. Thank you! – Mecanik May 16 '18 at 10:34
  • 1
    I got this working nicely, thanks for your example. However the only major thing missing is the progress... if you upload a 5 GB file it will take a while, and the only progress I get is the actual upload to my server, not the cloud. So this might be a challenge to do. – Mecanik May 29 '18 at 08:06

0 Answers0