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


Python File.upload_from_url方法代码示例

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


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

示例1: setUpClass

# 需要导入模块: from pyuploadcare.api_resources import File [as 别名]
# 或者: from pyuploadcare.api_resources.File import upload_from_url [as 别名]
    def setUpClass(cls):
        conf.pub_key = 'demopublickey'
        conf.secret = 'demoprivatekey'

        # create file to copy from
        file_from_url = File.upload_from_url(
            'https://github.com/images/error/angry_unicorn.png'
        )

        timeout = 30
        time_started = time.time()

        while time.time() - time_started < timeout:
            status = file_from_url.update_info()['status']
            if status in ('success', 'failed', 'error'):
                break
            time.sleep(1)

        cls.f = file_from_url.get_file()
        time_started = time.time()
        while time.time() - time_started < timeout:
            if cls.f.is_ready():
                break
            time.sleep(1)
            cls.f.update_info()
开发者ID:un33k,项目名称:pyuploadcare,代码行数:27,代码来源:test_api_resources.py

示例2: upload_from_url

# 需要导入模块: from pyuploadcare.api_resources import File [as 别名]
# 或者: from pyuploadcare.api_resources.File import upload_from_url [as 别名]
def upload_from_url(arg_namespace):
    if not _check_upload_args(arg_namespace):
        return
    file_from_url = File.upload_from_url(arg_namespace.url)
    pprint(file_from_url)

    if arg_namespace.wait or arg_namespace.store:
        timeout = arg_namespace.timeout
        time_started = time.time()
        while time.time() - time_started < timeout:
            status = file_from_url.update_info()['status']
            if status == 'success':
                break
            if status in ('failed', 'error'):
                raise UploadError(
                    'could not upload file from url: {0}'.format(
                        file_from_url.info())
                )
            time.sleep(1)
        else:
            raise TimeoutError('timed out during upload')

    if arg_namespace.store or arg_namespace.info:
        file_ = file_from_url.get_file()
        if file_ is None:
            pprint('Cannot store or get info.')
            return

        _handle_uploaded_file(file_, arg_namespace)
开发者ID:uploadcare,项目名称:pyuploadcare,代码行数:31,代码来源:__init__.py

示例3: test_successful_upload_from_url

# 需要导入模块: from pyuploadcare.api_resources import File [as 别名]
# 或者: from pyuploadcare.api_resources.File import upload_from_url [as 别名]
    def test_successful_upload_from_url(self):
        file_from_url = File.upload_from_url(
            'https://github.com/images/error/angry_unicorn.png'
        )

        timeout = 30
        time_started = time.time()

        while time.time() - time_started < timeout:
            status = file_from_url.update_info()['status']
            if status in ('success', 'failed', 'error'):
                break
            time.sleep(1)

        self.assertIsInstance(file_from_url.get_file(), File)
开发者ID:un33k,项目名称:pyuploadcare,代码行数:17,代码来源:test_api_resources.py

示例4: setUpClass

# 需要导入模块: from pyuploadcare.api_resources import File [as 别名]
# 或者: from pyuploadcare.api_resources.File import upload_from_url [as 别名]
    def setUpClass(cls):
        super(FileCopyTest, cls).setUpClass()

        # create file to copy from
        file_from_url = File.upload_from_url(
            'https://github.com/images/error/angry_unicorn.png'
        )

        timeout = 30
        time_started = time.time()

        while time.time() - time_started < timeout:
            status = file_from_url.update_info()['status']
            if status in ('success', 'failed', 'error'):
                break
            time.sleep(1)

        cls.f = file_from_url.get_file()
        time_started = time.time()
        while time.time() - time_started < timeout:
            if cls.f.is_ready():
                break
            time.sleep(1)
            cls.f.update_info()
开发者ID:uploadcare,项目名称:pyuploadcare,代码行数:26,代码来源:test_api_resources.py

示例5: test_successful_upload_from_url_sync

# 需要导入模块: from pyuploadcare.api_resources import File [as 别名]
# 或者: from pyuploadcare.api_resources.File import upload_from_url [as 别名]
 def test_successful_upload_from_url_sync(self):
     file_from_url = File.upload_from_url(
         'https://github.com/images/error/angry_unicorn.png'
     )
     file = file_from_url.wait(interval=1, until_ready=False)
     self.assertIsInstance(file, File)
开发者ID:un33k,项目名称:pyuploadcare,代码行数:8,代码来源:test_api_resources.py

示例6: test_get_some_token

# 需要导入模块: from pyuploadcare.api_resources import File [as 别名]
# 或者: from pyuploadcare.api_resources.File import upload_from_url [as 别名]
 def test_get_some_token(self):
     file_from_url = File.upload_from_url(
         'https://github.com/images/error/angry_unicorn.png'
     )
     self.assertTrue(file_from_url.token)
开发者ID:un33k,项目名称:pyuploadcare,代码行数:7,代码来源:test_api_resources.py


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