本文整理汇总了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()
示例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)
示例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)
示例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()
示例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)
示例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)