【问题标题】:Is it possible to use an HTTPS proxy with the aiobotocore Python module?是否可以将 HTTPS 代理与 aiobotocore Python 模块一起使用?
【发布时间】:2017-09-26 07:32:54
【问题描述】:

使用来自 Aiobotocore 网站的示例和这样的 HTTPS 代理:

import asyncio
import aiobotocore
from aiobotocore.config import AioConfig as Config

AWS_ACCESS_KEY_ID = "xxx"
AWS_SECRET_ACCESS_KEY = "xxx"


async def go(loop):
    bucket = 'dataintake'
    filename = 'dummy.bin'
    folder = 'aiobotocore'
    key = '{}/{}'.format(folder, filename)

    session = aiobotocore.get_session(loop=loop)
    conf = Config(proxies={'http': '<http_proxy>:<http_proxy_port>', 'https': '<https_proxy>:<https_proxy_port>'})
    async with session.create_client('s3', region_name='us-west-2',
                                   aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                                   aws_access_key_id=AWS_ACCESS_KEY_ID,
                                   config=conf) as client:
        # upload object to amazon s3
        data = b'\x01'*1024
        resp = await client.put_object(Bucket=bucket,
                                            Key=key,
                                            Body=data)
        print(resp)

        # getting s3 object properties of file we just uploaded
        resp = await client.get_object_acl(Bucket=bucket, Key=key)
        print(resp)

        # get object from s3
        response = await client.get_object(Bucket=bucket, Key=key)
        # this will ensure the connection is correctly re-used/closed
        async with response['Body'] as stream:
            assert await stream.read() == data

        # list s3 objects using paginator
        paginator = client.get_paginator('list_objects')
        async for result in paginator.paginate(Bucket=bucket, Prefix=folder):
            for c in result.get('Contents', []):
                print(c)

        # delete object from s3
        resp = await client.delete_object(Bucket=bucket, Key=key)
        print(resp)

loop = asyncio.get_event_loop()
loop.run_until_complete(go(loop))

我收到以下错误:

ValueError: Only http proxies are supported

是否有可能以其他方式将 HTTPS 代理与 aiobotocore 一起使用,或者修改源代码以支持 HTTPS 代理是否容易?

【问题讨论】:

    标签: python boto3 aiohttp botocore


    【解决方案1】:

    下划线 aiohttp 库不支持 HTTPS 代理。

    【讨论】:

    • 您好,感谢您的评论 - 我还发现了这篇文章:github.com/aio-libs/aiohttp/issues/845 在同一主题上。所以这似乎是背后的团队意识到的事情,但不是具有高优先级的事情。我会尝试寻找替代方案。
    猜你喜欢
    • 2011-01-31
    • 2023-01-04
    • 2013-11-13
    • 2016-08-11
    • 2021-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多