<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-07-29 9:46 GMT+02:00 Vincenzo Pii <span dir="ltr"><<a href="mailto:vinc.pii@gmail.com" target="_blank">vinc.pii@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">2015-07-29 8:01 GMT+02:00 Clint Byrum <span dir="ltr"><<a href="mailto:clint@fewbar.com" target="_blank">clint@fewbar.com</a>></span>:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Excerpts from John Dickinson's message of 2015-07-28 22:01:54 -0700:<br>
<span>> You can also use swiftclient.service module. It is the wrapper on top of the low-level swiftclient.client that is actually what the CLI tool uses for some of its higher-order functions (like splitting larger local files and making manifest objects).<br>
><br>
> You'd have something like:<br>
><br>
> results = swiftclient.service.upload('target_container', ['path/to/local/file',], options={'segment_size': 1048576000})<br>
><br>
<br>
</span>Indeed. To build on this, since you may have more than one cloud, we've<br>
added some pieces to the 'shade' library that figures out what segment<br>
sizes to use and just lets you pass in paths. Unfortunately I just<br>
noticed the create_object method isn't well documented, but I submitted<br>
a patch so here is that documentation:<br>
<br>
</span><a href="https://review.openstack.org/#/c/206872/1/shade/__init__.py" rel="noreferrer" target="_blank">https://review.openstack.org/#/c/206872/1/shade/__init__.py</a><span class=""><br>
<br>
Basically something like<br>
<br>
<br>
import shade<br>
<br>
cloud = shade.openstack_cloud()<br>
cloud.create_object('target_container', 'call me maybe', 'path/to/local/file')<br>
</span><div><div><br>
_______________________________________________<br>
Mailing list: <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack</a><br>
Post to     : <a href="mailto:openstack@lists.openstack.org" target="_blank">openstack@lists.openstack.org</a><br>
Unsubscribe : <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack</a><br>
</div></div></blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Hi Guys,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks for the inputs!</div><div class="gmail_extra"><br></div><div class="gmail_extra">I used the same flow as the CLI part of the swift client, as John suggested. I found it strange that the CLI and the python client APIs are not unified, I imagined that I would have found the same interfaces after some call layers.</div><div class="gmail_extra"><br></div><div class="gmail_extra">So this is what I did:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">import swiftclient.service</div><div class="gmail_extra">from swiftclient.service import SwiftService</div><div class="gmail_extra"><br></div><div class="gmail_extra">swiftclient.service._default_global_options['os_username'] = ''</div><div class="gmail_extra">swiftclient.service._default_global_options['os_password'] = ''</div><div class="gmail_extra">swiftclient.service._default_global_options['os_tenant_name'] = ''</div><div class="gmail_extra">swiftclient.service._default_global_options['os_auth_url'] = ''</div><div class="gmail_extra"><br></div><div class="gmail_extra">container_name = 'newcont'</div><div class="gmail_extra">filename = ['large_object']</div><div class="gmail_extra">segment_size = '1048576'</div><div class="gmail_extra"><br></div><div class="gmail_extra">with SwiftService() as sw:</div><div class="gmail_extra">    for r in sw.upload(container_name, filename, {'segment_size': segment_size}):</div><div class="gmail_extra">        print r['success']</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">The shade approach is actually the cleanest one!</div></div></div>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">I've opened this report: <a href="https://bugs.launchpad.net/python-swiftclient/+bug/1479284">https://bugs.launchpad.net/python-swiftclient/+bug/1479284</a></div></div>