2
votes

I've used the argument files =["abc.txt"]. I got the info from the airflow docs...https://airflow.readthedocs.io/en/stable/_modules/airflow/operators/email_operator.html

But I'm getting the error that the file is not found. My question is from where do this airflow will pick my file. Is it from GCS Bucket or DAG folder in the composer environment?

Where I need to upload a file and what is the correct syntax for 'files' argument?

Thanks in advance.

1
How to attach a file when it is in another bucket but not in the Airflow composer bucket? - Chakkirala Chaitanya
The link you have provided in the question at this moment is broken. - Carmoreno

1 Answers

1
votes

The files are taken from the local file system and the files argument is indeed a list of strings as files =["abc.txt"].

To upload the files to composer, you can use the data folder inside your Composer Environment GCS bucket, then you can access this data from /home/airflow/gcs/data/

An example taken from the documentation, with the files property added is:

from airflow.operators import email_operator
    # Send email confirmation
    email_summary = email_operator.EmailOperator(
        task_id='email_summary',
        to=models.Variable.get('email'),
        subject='Sample Email',
        html_content="HTML content",
        files=['/home/airflow/gcs/data/abc.txt'])

You can also download a file to the local system, and then send it; however, you'll need to ensure that the downloaded file and the email operators are executed by the same worker.