Upload data from Local Filesystem to Google Cloud Storage¶
The Google Cloud Storage (GCS) is used to store large data from various applications. This page shows how to upload data from local filesystem to GCS.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Select or create a Cloud Platform project using the Cloud Console.
Enable billing for your project, as described in the Google Cloud documentation.
Enable the API, as described in the Cloud Console documentation.
Install API libraries via pip.
pip install 'apache-airflow[google]'Detailed information is available for Installation.
LocalFilesystemToGCSOperator¶
LocalFilesystemToGCSOperator
allows you to upload
data from local filesystem to GCS.
When you use this operator, you can optionally compress the data being uploaded.
Below is an example of using this operator to upload a file to GCS.
upload_file = LocalFilesystemToGCSOperator(
task_id="upload_file",
src=UPLOAD_FILE_PATH,
dst=FILE_NAME,
bucket=BUCKET_NAME,
)