Ad
Ftp Does Not Transfer Complete File
I have the following code to transfer a file to another linux machine:
import ftplib
session = ftplib.FTP('192.168.1.111','ubuntu','ubuntu')
file = open('/home/nehal/darknet/yolo.weights','rb') # file to send
print(session.pwd())
print(ftplib.FTP.dir(session))
session.storbinary('STOR /home/ubuntu/yolo.weights',file) #send the file
file.close()
session.quit()
The file yolo.weights
is of 209MB and only few MBs are transferred.
I also tried transferring a file of 30MB but only a few MBs get transferred and it seems like no data is transferred thereafter.
What could be the issue?
Ad
Answer
When using STOR
you should pass only the filename and not the path. So to ensure the file ends up in the correct place, use .cwd()
to first specify the target directory:
import ftplib
session = ftplib.FTP('192.168.1.111','ubuntu','ubuntu')
file = open('/home/nehal/darknet/yolo.weights','rb') # file to send
print(session.pwd())
print(ftplib.FTP.dir(session))
session.cwd('/home/ubunto')
session.storbinary('STOR yolo.weights',file) #send the file
file.close()
session.quit()
Or you could try as follows:
import ftplib
session = ftplib.FTP('192.168.1.111', 'ubuntu', 'ubuntu')
file = open('/home/nehal/darknet/yolo.weights', 'rb')
with session, file:
print(session.pwd())
print(ftplib.FTP.dir(session))
session.cwd('/home/ubunto')
session.storbinary('STOR yolo.weights', file)
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad