def store(self, data, blob): if not isinstance(data, unicode): raise NotStorable("Could not store data (not of 'unicode' " "type).") data = data.encode('UTF-8') StringStorable.store(self, data, blob)
def store(self, data, blob): if not isinstance(data, str): raise NotStorable("Could not store data (not of 'str' type).") fp = blob.open('w') fp.write(data) fp.close()
def store(self, data, blob): if not isinstance(data, file): raise NotStorable('Could not store data (not of "file").') filename = getattr(data, 'name', None) if filename is not None: blob.consumeFile(filename) return
def store(self, data, blob): if not isinstance(data, file): raise NotStorable("Could not store data (not of 'file').") filename = getattr(data, "name", None) if filename is not None: blob.consumeFile(filename) return
def store(self, data, blob): if not isinstance(data, TemporaryFileWrapper): msg = 'Could not store data (not of TemporaryFileWrapper type)' raise NotStorable(msg) filename = getattr(data, 'name', None) if filename is not None: blob.consumeFile(filename)
def store(self, data, blob): raw = data.raw if not isinstance(raw, io.FileIO): raise NotStorable('Could not store data (not of type "io.FileIO")') filename = getattr(data.raw, 'name', None) if filename is not None: blob.consumeFile(filename) return
def store(self, data, blob): if not isinstance(data, FileChunk): raise NotStorable('Could not store data (not a of "FileChunk" type).') # noqa with blob.open('w') as fp: chunk = data while chunk: fp.write(chunk._data) chunk = chunk.next
def store(self, data, blob): if not isinstance(data, FileChunk): raise NotStorable("Could not store data (not a of 'FileChunk' " "type).") fp = blob.open('w') chunk = data while chunk: fp.write(chunk._data) chunk = chunk.next fp.close()
def store(self, data, blob): if not isinstance(data, FileUpload): raise NotStorable('Could not store data (not of "FileUpload").') data.seek(0) with blob.open('w') as fp: block = data.read(MAXCHUNKSIZE) while block: fp.write(block) block = data.read(MAXCHUNKSIZE)
def store(self, data, blob): if not isinstance(data, FileUpload): raise NotStorable("Could not store data (not of 'FileUpload').") data.seek(0) fp = blob.open('w') block = data.read(MAXCHUNKSIZE) while block: fp.write(block) block = data.read(MAXCHUNKSIZE) fp.close()
def store(self, data, blob): if not isinstance(data, file): raise NotStorable("Could not store data (not of 'file').") # The original used consumeFile which tries to move a file if possible # filename = getattr(data, "name", None) # if filename is not None: # blob.consumeFile(filename) # return # Let us use any file object and just copy it import logging logging.getLogger("BLOB PATCH").info("USE MY BLOB STORAGE ADAPTER") dest = blob.open('w') # TODO: should we seek to 0? shutil.copyfileobj(data, dest)
def store(self, data, blob): if not isinstance(data, _TemporaryFileWrapper): raise NotStorable('Could not store data (not a ' '"_TemporaryFileWrapper").') _chunked_transfer(data, blob)
def store(self, pdata, blob): if not isinstance(pdata, Pdata): raise NotStorable('Could not store data (not of "Pdata").') fp = blob.open('w') fp.write(str(pdata)) fp.close()
def store(self, data, blob): if not isinstance(data, six.text_type): raise NotStorable('Could not store data (not of "unicode" type).') data = data.encode('UTF-8') StringStorable.store(self, data, blob)
def store(self, data, blob): if not isinstance(data, str): raise NotStorable('Could not store data (not of "str" type).') with blob.open('w') as fp: fp.write(data)
def store(self, data, blob): if not isinstance(data, FileUpload): raise NotStorable('Could not store data (not of "FileUpload").') _chunked_transfer(data, blob)
def store(self, data, blob): if not isinstance(data, six.binary_type): raise NotStorable('Could not store data (not of bytes type).') with blob.open('w') as fp: fp.write(data)