Q:

TypeError: expected string or bytes-like object - how to copy files to an S3 bucket using the code provided in AWS's documentation

https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html
Using the code provided in the documentation, I'm trying to iterate through parent_dir, and if there's a zip file, then I want to copy it to my S3 bucket.  
I tried both
    try:
        response = s3_client.upload_file(file_name, bucket, object_name)
    except ClientError as e:
        logging.error(e)
        return False
    return True

and
s3 = boto3.client('s3')
with open("FILE_NAME", "rb") as f:
    s3.upload_fileobj(f, "BUCKET_NAME", "OBJECT_NAME")

but both of them gave the same error.  
    s3_client = boto3.client(
        's3',
        aws_access_key_id='MY_KEY_ID',
        aws_secret_access_key='MY_ACCESS_KEY'
    )

    session = boto3.Session(
        aws_access_key_id='MY_KEY_ID',
        aws_secret_access_key='MY_ACCESS_KEY',
    )

    s3 = session.resource('s3')
    bucket = s3.Bucket('MY_URL')

    for file in os.listdir(parent_dir):
        if object_name is None:
            object_name = file

        if file.endswith('.zip'):
            with open(file, "rb") as f:
                s3_client.upload_fileobj(f, bucket, object_name)

TypeError: expected string or bytes-like object

A:

According to [AmazonAWS.Boto3]: S3.Client - upload_fileobj(Fileobj, Bucket, Key, ExtraArgs=None, Callback=None, Config=None), the 2nd and 3rd arguments (Bucket and Key) must be strings. 
But you are passing as a 2nd argument:
bucket = s3.Bucket('MY_URL')

which is not OK.  Make it a plain string (and even better, rename it):
bucket_name = "MY_URL"

and pass it to upload_fileobj, and you should get past this problem.