Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
15182 Lượt xem

Hi, I need to upload the binary file to ftp automatically from pyhton how can i achieve this?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Maniganda

you can like below

import some class in your .py file

from ftplib import FTP


objec=FTP("yourIP")
objec.login("youruser","passs")
objec.storbinary('STOR yourfile.txt', open('yourexixtingfile.txt', 'rb'))
objec.close()

After successfull login

use properties of objec object such as upload reload ,read file from etc...... hope this is help you just see the objec FTP's method you can it easily

Thanks
Sandeep

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks for your Reply Sandeep , but i am getting the error as gaierror: [Errno -2] Name or service not known

try to check your FTP user and password

Câu trả lời hay nhất

you can use the built-in ftp library (http://stackoverflow.com/questions/12613797/python-script-uploading-files-via-ftplink text) or you can avoid using ftp and trying via xml-rpc that's a more stable solution IMO.

If you need to understand how to deal with xml-rpc, you can look at the official docs here:

https://doc.openerp.com/6.1/developer/12_api/#xml-rpc-web-services.

do not forget that XML-RPC cannot manage binary files as-is, you'll have to read the content and convert it into a base64 string.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 24
1200
0
thg 9 22
2631
0
thg 3 15
3326
0
thg 3 15
3770
1
thg 3 15
6633