Skip to content Skip to sidebar Skip to footer

Can We Send Data From Google Cloud Storage To Sftp Server Using Gcp Cloud Function?

I want to take a .csv file from Google cloud storage and send it to SFTP server. I do not know, what I am doing wrong, but I am getting the error that file not found in the cloud s

Solution 1:

The pysftp does not understand gs://.

Instead, use Google API to download the file to SFTP file-like object representing the target file on the SFTP server opened with the pysftp:

storage_client = storage.Client()

bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(source_blob_name)
with sftp.open(remotepath, 'w', 32768) as f:
    blob.download_to_file(f)

Post a Comment for "Can We Send Data From Google Cloud Storage To Sftp Server Using Gcp Cloud Function?"