Skip to content

Add create_intermediate_dirs option to GCSToSFTPOperator #54906

@hlakki31-arch

Description

@hlakki31-arch

Description

Proposal

Add a create_intermediate_dirs parameter to GCSToSFTPOperator, similar to SFTPOperator, to allow skipping automatic directory creation.

Problem:
Currently, GCSToSFTPOperator always calls create_directory() on the remote SFTP path, which can fail with permission errors when uploading to existing folders (e.g., /landing_folder/) where users don’t have permission to create new directories.

Proposed Solution:

  • Add a boolean parameter create_intermediate_dirs (default=True).
  • When set to False, skip the create_directory() call and upload directly to the specified folder.

Benefits:

  • Allows uploading to existing folders without needing to modify SFTP permissions.
  • Matches behavior of SFTPOperator, making the API more consistent.

Use case/motivation

The goal is to upload files from GCS to SFTP reliably even when the target folder exists and directory creation permissions are restricted. This prevents PermissionError failures and makes GCSToSFTPOperator more consistent with other SFTP operators.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions