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


Python Connection.add_file_to_resource方法代码示例

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


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

示例1: test_23_basic_add_content_to_resource_single_file

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import add_file_to_resource [as 别名]
 def test_23_basic_add_content_to_resource_single_file(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href, 
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip')
     receipt = conn.get_deposit_receipt(receipt.location)
     
     with open(PACKAGE) as pkg:
         new_receipt = conn.add_file_to_resource(receipt.edit_media, pkg, "addition.zip", mimetype=PACKAGE_MIME)
     
     assert new_receipt.code >= 200 and new_receipt.code < 400
     assert new_receipt.location is not None
     assert new_receipt.location != receipt.edit_media
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:20,代码来源:test_pylons.py

示例2: test_26_advanced_add_content_to_resource_package

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import add_file_to_resource [as 别名]
 def test_26_advanced_add_content_to_resource_package(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
     conn.get_service_document()
     col = conn.sd.workspaces[0][1][0]
     with open(PACKAGE) as pkg:
         receipt = conn.create(col_iri = col.href, 
                     payload=pkg, 
                     mimetype=PACKAGE_MIME, 
                     filename="example.zip",
                     packaging = 'http://purl.org/net/sword/package/SimpleZip',
                     in_progress=True)
     receipt = conn.get_deposit_receipt(receipt.location)
     
     with open(PACKAGE) as pkg:
         new_receipt = conn.add_file_to_resource(receipt.edit_media, pkg, "addition.zip", 
                                                 mimetype=PACKAGE_MIME,
                                                 packaging="http://purl.org/net/sword/package/SimpleZip",
                                                 metadata_relevant=True)
     
     assert new_receipt.code >= 200 and new_receipt.code < 400
     assert new_receipt.location is not None
     assert new_receipt.location == receipt.edit_media
开发者ID:dataflow,项目名称:python-client-sword2,代码行数:24,代码来源:test_spec.py


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