On 5 January 2014 00:57, Andy Bunce wrote:
Hi,
curl -X PUT -T aa.pdf http://localhost:9998/tika [...] I have tried: let $file:="C:\tmp\aa.pdf" let $request := <http:request method='PUT' > <http:body media-type="application/octet-stream">{ fetch:binary($file) }</http:body> </http:request>
I do not know Tika, I do not have BaseX on this machine, and you did not give a lot of details about what is not working nor error messages, so it is a bit difficult to help here. All I can say is that I would use the following as the EXPath HTTP Client equivalent to the above CURL command:
<http:request method="put"> <http:body media-type="application/pdf" src="file:/c:/tmp/aa.pdf"/> </http:request>
The @media-type is mandatory. You do not set any explicitly with CURL, so you should probably find which MIME type works with CURL in the first place. The @src lets the processor handle the details of accessing the binary file, which makes things easier and then you are sure the problem is not with fetch:binary() or with the analysis of the binary content of http:body.
If you find a MIME type that works with CURL (you can use the -H option like the following: -H "Content-Type: application/pdf"), and it is still failing, tcpdump can help as well. Open a terminal window, and execute the following:
sudo tcpdump -s 0 -A -i any tcp and host localhost and port 9998
This will dump all traffic to localhost:9998. Then go to another terminal window (because tcpdump is still running) and execute the CURL command. After the completion, go back to the first window and press Ctrl-C (to kill tcpdump). In between, tcpdump has output to the console a dump of the request. It will as well if you keep it running when you test your query in BaseX. So you can compare both requests and see what is different (or post it here so we can see what is happening).
Regards,