문제

I'm now writing a Corba project to do file transfering between client and server. But I face trouble when I want to upload file from the client to the server.

The IDL I defined is:

interface SecretMessage
{
    string send_file(in string file_name, in string file_obj);
};

And I implemented the uploading function in the client code:

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

result = mo.send_file('2.docx', data)

If the file is a plain txt file, there is no problem. But if the file is a, like jpg, doc, or others except txt, then it does work. It gives me the error:

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

Where is the problem?

도움이 되었습니까?

해결책

I think it is because by default omniORB wants to see ASCII data for strings. Try changing your IDL to this

interface SecretMessage
{
    typedef sequence<octet> OctetSequence;
    string send_file(in string file_name, in OctetSequence file_obj);
};

You can keep your Python client code the same because in the IDL to Python mapping, octet sequences map to Python strings.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top