Esempio n. 1
0
    def get(self, userId: str, bucket: str, key: str) -> bytes:
        if not self.initialized:
            raise Exception("archive not initialized")

        try:
            with db.session_scope() as dbsession:
                result = db_objectstorage.get(userId, bucket, key, session=dbsession)
                if result and 'content' in result:
                    data = result.get('content')
                    # Clean return of empty
                    if data is None:
                        return b''
                    else:
                        return utils.ensure_bytes(result.get('content'))
                else:
                    raise ObjectKeyNotFoundError(userId, bucket, key, caused_by=None)
        except Exception as err:
            logger.debug("cannot get data: exception - " + str(err))
            raise err
Esempio n. 2
0
    def get(self, userId, bucket, key):
        if not self.initialized:
            raise Exception("archive not initialized")

        try:
            with db.session_scope() as dbsession:
                result = db_objectstorage.get(userId,
                                              bucket,
                                              key,
                                              session=dbsession)
                if result and 'content' in result:
                    return result.get('content')
                else:
                    raise ObjectKeyNotFoundError(userId,
                                                 bucket,
                                                 key,
                                                 caused_by=None)
        except Exception as err:
            logger.debug("cannot get data: exception - " + str(err))
            raise err