Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何编写基于omniORBpy的文件传输程序_Python_Corba_Omniorb - Fatal编程技术网

Python 如何编写基于omniORBpy的文件传输程序

Python 如何编写基于omniORBpy的文件传输程序,python,corba,omniorb,Python,Corba,Omniorb,我现在正在编写一个Corba项目来完成客户端和服务器之间的文件传输。 但是,当我想将文件从客户端上传到服务器时,我会遇到麻烦 我定义的IDL是: interface SecretMessage { string send_file(in string file_name, in string file_obj); }; 我在客户端代码中实现了上传功能: f = open('SB.docx', 'rb') data = '' for piece in read_in_chunks(f):

我现在正在编写一个Corba项目来完成客户端和服务器之间的文件传输。 但是,当我想将文件从客户端上传到服务器时,我会遇到麻烦

我定义的IDL是:

interface SecretMessage
{
    string send_file(in string file_name, in string file_obj);
};
我在客户端代码中实现了上传功能:

f = open('SB.docx', 'rb')
data = ''
for piece in read_in_chunks(f):
    data += piece

result = mo.send_file('2.docx', data)
如果文件是普通txt文件,则没有问题。 但是如果文件是一个文件,比如jpg、doc或txt以外的其他文件,那么它就可以工作了。 它给了我一个错误:

omniORB.CORBA.BAD_PARAM: CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)

问题出在哪里?

我认为这是因为默认情况下,omniORB希望看到字符串的ASCII数据。尝试将IDL更改为此

interface SecretMessage
{
    typedef sequence<octet> OctetSequence;
    string send_file(in string file_name, in OctetSequence file_obj);
};
interface SecretMessage
{
typedef序列八位序列;
字符串发送文件(在字符串文件名中,在八进制序列文件中);
};
您可以保持Python客户机代码不变,因为在IDL到Python的映射中,八位字节序列映射到Python字符串