コード例 #1
0
ファイル: s3_to_ftp.py プロジェクト: ysktir/airflow-1
    def execute(self, context):
        s3_hook = S3Hook(self.aws_conn_id)
        ftp_hook = FTPHook(ftp_conn_id=self.ftp_conn_id)

        s3_obj = s3_hook.get_key(self.s3_key, self.s3_bucket)

        with NamedTemporaryFile() as local_tmp_file:
            s3_obj.download_fileobj(local_tmp_file)
            ftp_hook.store_file(self.ftp_path, local_tmp_file.name)
コード例 #2
0
    def execute(self, context: 'Context'):
        s3_hook = S3Hook(self.aws_conn_id)
        ftp_hook = FTPHook(ftp_conn_id=self.ftp_conn_id)

        s3_obj = s3_hook.get_key(self.s3_key, self.s3_bucket)

        with NamedTemporaryFile() as local_tmp_file:
            self.log.info('Downloading file from %s', self.s3_key)
            s3_obj.download_fileobj(local_tmp_file)
            local_tmp_file.seek(0)
            ftp_hook.store_file(self.ftp_path, local_tmp_file.name)
            self.log.info('File stored in %s', {self.ftp_path})