Example #1
0
    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)
Example #2
0
    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()
Example #3
0
    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
Example #4
0
    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
Example #5
0
    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)
Example #6
0
    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
Example #7
0
    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
Example #8
0
    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()
Example #9
0
    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)
Example #10
0
    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()
Example #11
0
    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)
Example #12
0
    def store(self, data, blob):
        if not isinstance(data, _TemporaryFileWrapper):
            raise NotStorable('Could not store data (not a '
                              '"_TemporaryFileWrapper").')

        _chunked_transfer(data, blob)
Example #13
0
 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()
Example #14
0
    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)
Example #15
0
    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)
Example #16
0
    def store(self, data, blob):
        if not isinstance(data, FileUpload):
            raise NotStorable('Could not store data (not of "FileUpload").')

        _chunked_transfer(data, blob)
Example #17
0
    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)