Small fixes to bugs in the streaming handler for use with magic and radosgw.
This commit is contained in:
parent
d2d51d15a2
commit
c9e1648781
4 changed files with 25 additions and 13 deletions
|
@ -7,23 +7,19 @@ import boto.gs.connection
|
|||
import boto.s3.key
|
||||
import boto.gs.key
|
||||
|
||||
from io import UnsupportedOperation, BufferedIOBase
|
||||
|
||||
from storage.basestorage import BaseStorage
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StreamReadKeyAsFile(object):
|
||||
class StreamReadKeyAsFile(BufferedIOBase):
|
||||
def __init__(self, key):
|
||||
self._key = key
|
||||
self._finished = False
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
self._key.close(fast=True)
|
||||
|
||||
def read(self, amt=None):
|
||||
if self._finished:
|
||||
return None
|
||||
|
@ -33,6 +29,16 @@ class StreamReadKeyAsFile(object):
|
|||
self._finished = True
|
||||
return resp
|
||||
|
||||
def readable(self):
|
||||
return True
|
||||
|
||||
@property
|
||||
def closed(self):
|
||||
return self._key.closed
|
||||
|
||||
def close(self):
|
||||
self._key.close(fast=True)
|
||||
|
||||
|
||||
class _CloudStorage(BaseStorage):
|
||||
def __init__(self, connection_class, key_class, connect_kwargs, upload_params, storage_path,
|
||||
|
|
Reference in a new issue