当前位置: 首页>>代码示例>>Python>>正文


Python FileInstance.get方法代码示例

本文整理汇总了Python中invenio_files_rest.models.FileInstance.get方法的典型用法代码示例。如果您正苦于以下问题:Python FileInstance.get方法的具体用法?Python FileInstance.get怎么用?Python FileInstance.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invenio_files_rest.models.FileInstance的用法示例。


在下文中一共展示了FileInstance.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fileinstance_get

# 需要导入模块: from invenio_files_rest.models import FileInstance [as 别名]
# 或者: from invenio_files_rest.models.FileInstance import get [as 别名]
def test_fileinstance_get(app, db, dummy_location):
    """Test fileinstance get."""
    f = FileInstance.create()
    db.session.commit()
    # Get existing file.
    assert FileInstance.get(f.id) is not None
    # Non-existing files returns none
    assert FileInstance.get(uuid.uuid4()) is None
开发者ID:jirikuncar,项目名称:invenio-files-rest,代码行数:10,代码来源:test_models.py

示例2: upload_to_zenodo

# 需要导入模块: from invenio_files_rest.models import FileInstance [as 别名]
# 或者: from invenio_files_rest.models.FileInstance import get [as 别名]
def upload_to_zenodo(bucket_id, filename):
    """Upload code to zenodo."""
    zenodo_server_url = current_app.config.get('ZENODO_SERVER_URL')
    params = {"access_token": current_app.config.get(
        'ZENODO_ACCESS_TOKEN')}
    filename = filename + '.tar.gz'

    r = requests.post(zenodo_server_url,
                      params=params, json={},
                      )

    file_obj = ObjectVersion.get(bucket_id, filename)
    file = FileInstance.get(file_obj.file_id)

    bucket_url = r.json()['links']['bucket']
    with open(file.uri, 'rb') as fp:
        response = requests.put(
            bucket_url + '/{}'.format(filename),
            data=fp,
            params=params,
        )

    return jsonify({"status": response.status_code})
开发者ID:cernanalysispreservation,项目名称:analysis-preservation.cern.ch,代码行数:25,代码来源:zenodo.py


注:本文中的invenio_files_rest.models.FileInstance.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。