Implement stream_read_file
for the Swift storage engine
Note that Swift doesn't seem to have a file-like interface, so we need to wrap the generator we get back from it. Fixes #210
This commit is contained in:
parent
cb238f8764
commit
4333bb9e14
3 changed files with 127 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
""" Swift storage driver. Based on: github.com/bacongobbler/docker-registry-driver-swift/ """
|
||||
from swiftclient.client import Connection, ClientException
|
||||
from storage.basestorage import BaseStorage
|
||||
from util.generatorfile import GeneratorFile
|
||||
|
||||
from random import SystemRandom
|
||||
import string
|
||||
|
@ -8,6 +9,7 @@ import logging
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SwiftStorage(BaseStorage):
|
||||
def __init__(self, swift_container, storage_path, auth_url, swift_user,
|
||||
swift_password, auth_version=None, os_options=None, ca_cert_path=None):
|
||||
|
@ -143,7 +145,7 @@ class SwiftStorage(BaseStorage):
|
|||
yield data
|
||||
|
||||
def stream_read_file(self, path):
|
||||
raise NotImplementedError
|
||||
return GeneratorFile(self.stream_read(path))
|
||||
|
||||
def stream_write(self, path, fp, content_type=None, content_encoding=None):
|
||||
self._put_object(path, fp, self.buffer_size, content_type=content_type,
|
||||
|
|
Reference in a new issue