本文整理汇总了Python中psi.app.service.Info.get_image_store_service方法的典型用法代码示例。如果您正苦于以下问题:Python Info.get_image_store_service方法的具体用法?Python Info.get_image_store_service怎么用?Python Info.get_image_store_service使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psi.app.service.Info
的用法示例。
在下文中一共展示了Info.get_image_store_service方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handle_image_delete
# 需要导入模块: from psi.app.service import Info [as 别名]
# 或者: from psi.app.service.Info import get_image_store_service [as 别名]
def _handle_image_delete(mapper, conn, target):
"""
Delete the local or remote image from 3rd service when delete the image.
if path is not empty, assume local storage, delete using after_delete
listener, if public_id is not null, assume using cloud service, delete
using public_id.
:param mapper:
:param conn:
:param target: image object to be deleted
:return:
"""
# TODO.xqliu The delete of image is not working for local image store
Info.get_image_store_service().remove(target.path, target.public_id)
示例2: save_image
# 需要导入模块: from psi.app.service import Info [as 别名]
# 或者: from psi.app.service.Info import get_image_store_service [as 别名]
def save_image(owner, image_file):
"""
Save image to an owner object
:param service: The service to save the image,
use to isolate different storage service
:param owner: Owner of this image object
:param image_file: File storage object of the image
:return: The image object created
"""
from psi.app.models import Image
service = Info.get_image_store_service()
if owner.image is not None:
existing_img_public_id = owner.image.path
service.remove(existing_img_public_id)
image = Image()
owner.image = image
public_id = str(uuid.uuid4())
result = service.save(image_file, public_id=public_id)
owner.image.path = result['url']
owner.image.public_id = public_id
return image