Closed cakovacs closed 11 years ago
I added the debugging code in {Emit,Receive}FileDirect.h if it helps resolve the problem.
If you want to send file and receive file over the qamqp, you can try this: void publish(const QByteArray & message, const QString & key, const QString &mimeType, const MessageProperties &property = MessageProperties());
Note: mimeType mustn't be "text/plain", you can set it to "image/jpeg" or other binary mimetypes. Then you can receive all the file data.
ximply,
That's not my problem. I did set the mimeType to a binary type and able to correctly send/receive binary files using the publish method.
My problem is that I would like to send the filename in the message headers, which fails. My workaround was to include the filename in the payload and extracting the filename in the receiver (ie., payload = "[" + filename + "]" + file_contains).
I'm trying to use the following interface to send the filename inside the QVariantHash &headers argument:
void publish(const QByteArray & message, const QString & key, const QVariantHash &headers, const QString &mimeType, const MessageProperties &property = MessageProperties());
When I print the headers in the sender, the keys and values are present. When I print the headers in the receiver, the keys are there, but the values are all empty.
I added debugging info in EmitFileDirect.h and ReceiveFileDirect.h and push it to my branch. I'm hoping someone can tell me what I'm doing wrong.
I fix it. Update to revision 1a05e873cbb414ff75dd6a2ffd5eaf05587234f0
I verified the fix on my branch and pushed my changes. Thanks fuCtor
I wrote a EmitFileDirect and ReceiveFileDirect test code and check it into the repo under my branch. I was unable to figure out how to use the message headers. I put in a workaround by embedding the filename in the message, but I would really like to take advantage of the headers. If I'm doing something wrong, please help me with the interface. If it's a bug in the backend code, please fix it if possible.
In the Emit class, I added the following code:
When I run the EmitFileDirect test, it prints out the correct information in the headers:
EmitFileDirect::EmitFileMessage() headers= QHash(("fname", QVariant(QString, "event0000001.bin") ) ( "A" , QVariant(QString, "AAAAAAAAAAA") ) ( "B" , QVariant(QString, "BBBBB") ) ( "C" , QVariant(QString, "CCCCCCCCCCCCCCCCC") ) )
The problem is in the Receiver. In the ReceiveFileDirect.h, I have the following snip-it of code:
When I run it, it gets all of the keys, but the values are all null:
ReceiverFileDirect::newMessage() headers= QVariant(QVariantHash, QHash(("fname", QVariant(QString, "") ) ( "A" , QVariant(QString, "") ) ( "B" , QVariant(QString, "") ) ( "C" , QVariant(QString, "") ) ) )
I added the following debug code to verify that they were actually null:
And it printed out the following:
"fname" : QVariant(QString, "") "A" : QVariant(QString, "") "B" : QVariant(QString, "") "C" : QVariant(QString, "")