本文整理汇总了Python中invenio_files_rest.models.FileInstance.set_uri方法的典型用法代码示例。如果您正苦于以下问题:Python FileInstance.set_uri方法的具体用法?Python FileInstance.set_uri怎么用?Python FileInstance.set_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invenio_files_rest.models.FileInstance
的用法示例。
在下文中一共展示了FileInstance.set_uri方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_file
# 需要导入模块: from invenio_files_rest.models import FileInstance [as 别名]
# 或者: from invenio_files_rest.models.FileInstance import set_uri [as 别名]
def create_file(self, bucket, f):
"""Create a single file."""
# Ensure that file instance get's created with the same ID as it is
# used in the REST API.
fileinstance = FileInstance(
id=f['id'],
writable=True,
readable=False,
size=0,
)
db.session.add(fileinstance)
fileinstance.set_uri(f['uri'], f['size'], f['checksum'])
obj = ObjectVersion.create(bucket, f['key']).set_file(fileinstance)
return (dict(
bucket=str(obj.bucket.id),
key=obj.key,
checksum=obj.file.checksum,
size=obj.file.size,
version_id=str(obj.version_id),
type=f['type'],
), fileinstance)