Manual file uploads

Example allowing users to manually upload files using a Streamlit app. The uploaded files are stored on an AWS S3 bucket:

from io import BytesIO
import boto3

aws_access_key_id = "your_aws_access_key_id"
aws_secret_access_key = "your_aws_secret_access_key"
region_name = "your_aws_region_name"
aws_bucket_name = "my-bucket-name"

uploaded_files = st.file_uploader("Choose files", accept_multiple_files = True, type = ['pdf','png'])
if uploaded_files:
  s3_client = boto3.client(
      's3',
      aws_access_key_id = aws_access_key_id,
      aws_secret_access_key= aws_secret_access_key,
      region_name = region_name
    ) 
    for uploaded_file in uploaded_files:
        if uploaded_file is not None:
            s3_client.upload_fileobj(BytesIO(uploaded_file.read()), aws_bucket_name, uploaded_file.name)