def handle_uploads()

in invoice-processing-pipeline/uploader/main.py [0:0]


def handle_uploads():
    BUCKET_NAME = os.environ.get("BUCKET")
    client = storage.Client()

    try:
        bucket = client.get_bucket(BUCKET_NAME)
    except Exception as e:
        return f"Could not open bucket: {e}", 400

    handled = 0
    for key in request.files:
        for file in request.files.getlist(key):
            if uploaded_to_storage(file, bucket):
                handled += 1

    return f"Uploaded {handled} file(s)", 200