Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PUTting an object to S3 using aiohttp and aws_sig_v4_headers
import asyncio
import os
import aiohttp
from aws_sig_v4_headers import aws_sig_v4_headers
async def main():
method = 'PUT'
host = ''
path = f'/my-bucket-name/my-object-key'
data = b'This is the data'
pre_auth_headers = {}
query = {}
headers = aws_sig_v4_headers(os.environ['AWS_ACCESS_KEY_ID'], os.environ['AWS_SECRET_ACCESS_KEY'], pre_auth_headers,
's3', 'eu-west-1', host, method, path, query, data)
async with aiohttp.ClientSession() as session:
async with session.request(method, f'https://{host}{path}', headers=headers, data=data) as response:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.