You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by "torf (JIRA)" <ji...@apache.org> on 2015/09/04 10:34:46 UTC
[jira] [Resolved] (LIBCLOUD-725) Binary data storage in
LocalStorageDriver fails on Py3
[ https://issues.apache.org/jira/browse/LIBCLOUD-725?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
torf resolved LIBCLOUD-725.
---------------------------
Resolution: Fixed
Fix has been merged.
> Binary data storage in LocalStorageDriver fails on Py3
> ------------------------------------------------------
>
> Key: LIBCLOUD-725
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-725
> Project: Libcloud
> Issue Type: Bug
> Components: Storage
> Environment: LibCloud 0.17.0, Python 3.4
> Reporter: torf
>
> {{LocalStorageDriver.upload_object_via_stream}} does not allow the upload of bytes in Python 3, despite the fact that {{download_object_as_stream}} returns a stream of bytes:
> {code}
> >>> container.upload_object_via_stream(io.BytesIO(b'foobar'), 'key')
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File
> "/home/torf/projects/coba/venv/lib/python3.4/site-packages/libcloud/storage/base.py",
> line 157, in upload_object_via_stream
> iterator, self, object_name, extra=extra, **kwargs)
> File
> "/home/torf/projects/coba/venv/lib/python3.4/site-packages/libcloud/storage/drivers/local.py",
> line 497, in upload_object_via_stream
> obj_file.close()
> File
> "/home/torf/projects/coba/venv/lib/python3.4/site-packages/libcloud/storage/drivers/local.py",
> line 69, in __exit__
> raise value
> File
> "/home/torf/projects/coba/venv/lib/python3.4/site-packages/libcloud/storage/drivers/local.py",
> line 495, in upload_object_via_stream
> obj_file.write(data)
> TypeError: must be str, not bytes
> {code}
> The problem is that {{LocalStorageDriver}} opens the target file for writing in text mode ({{'w'}}) instead of binary mode ({{'wb'}}).
> As discussed on the users mailing list I am working on a pull request for this issue.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)