def put(self, userId: str, bucket: str, key: str, data: bytes) -> str: if not self.initialized: raise Exception("archive not initialized") try: d = utils.ensure_bytes(data) with db.session_scope() as dbsession: if db_objectstorage.put(userId, bucket, key, d, session=dbsession): return self.uri_for(userId, bucket, key) else: raise Exception('Db operation to save object returned failure') except Exception as err: logger.debug("cannot put data: exception - " + str(err)) raise err
def put(self, userId, bucket, key, data, metadata=None): if not self.initialized: raise Exception("archive not initialized") try: with db.session_scope() as dbsession: if db_objectstorage.put(userId, bucket, key, bytearray(data.encode('utf8')), metadata=metadata, session=dbsession): return self.uri_for(userId, bucket, key) else: raise Exception( 'Db operation to save object returned failure') except Exception as err: logger.debug("cannot put data: exception - " + str(err)) raise err