Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SFTP in Django
#1
I need to download a file from the SFTP server and store it in local machine,and also upload a file from my local system to the SFTP server.
I need to do this django project
I got a code from google and the code goes like this
import pysftp

Hostname = "remote-ip-address"
Username = "root"
Password = "password"

with pysftp.Connection(host=Hostname, username=Username, password=Password) as sftp:
print("Connection successfully established ... ")

# Define the remote path where the file will be uploaded
remoteFilePath = '/etc/hosts'

# Define a file that you want to upload from your local directorty
localFilePath = '/opt/hosts'

# Use get method to download a file
sftp.get(remoteFilePath, localFilePath)
how do i accomodate this in Django project ?
Is there any way specific in Django to do this?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,337 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020