Closed bx5974 closed 9 years ago
Getting curl: (52) Empty reply from server
curl --include \ --request POST \ --header "Content-Type: multipart/related; boundary=---BOUNDARY" \ --data-binary '-----BOUNDARY Content-Disposition: attachment; Content-Type: image/png filename="ocrimage.png".
PNGDATA......... -----BOUNDARY' \ http://172.16.0.20:8080/ocr-file-upload curl: (52) Empty reply from server
Looks like you are missing the application/json
part. Here are some docs that describe the request the server is expecting:
From https://app.apiary.io/openocr:
+ Request (multipart/related; boundary=---BOUNDARY)
-----BOUNDARY
Content-Type: application/json
{"img_url":"http://bit.ly/ocrimage","engine":"tesseract"}
-----BOUNDARY
-----BOUNDARY
Content-Disposition: attachment;
Content-Type: image/png
filename="attachment.txt".
PNGDATA.........
-----BOUNDARY
I'm closing the ticket because I don't think its a bug, but feel free to continue the discussion here.
Sorry i am confused, here -
1/ Why should we provide, http://bit.ly/ocrimage - when we need to upload local image for OCR ?
2/ also PNGDATA......... (is it base64 of the image) ?
Please guide me
Sorry to jump on this thread, but is there a general user listserv? Or a more accepted way of posting simple questions than launching a ticket?
Thanks,
JG — Sent from Mailbox
On Sat, Nov 22, 2014 at 4:50 PM, Traun Leyden notifications@github.com wrote:
- If you upload local image, no need to provide , http://bit.ly/ocrimage
2. Raw data, not base64
Reply to this email directly or view it on GitHub: https://github.com/tleyden/open-ocr/issues/23#issuecomment-64096887
For now use github, but I think a google group may be in order.
On Nov 22, 2014, at 4:17 PM, John T Green notifications@github.com wrote:
Sorry to jump on this thread, but is there a general user listserv? Or a more accepted way of posting simple questions than launching a ticket?
Thanks,
JG — Sent from Mailbox
On Sat, Nov 22, 2014 at 4:50 PM, Traun Leyden notifications@github.com wrote:
- If you upload local image, no need to provide , http://bit.ly/ocrimage
2. Raw data, not base64
Reply to this email directly or view it on GitHub: https://github.com/tleyden/open-ocr/issues/23#issuecomment-64096887 — Reply to this email directly or view it on GitHub.
Sorry, what you mean by raw data? can please you be clear?
how do you run a CURL command for local image file at /tmp/ocrimage.png
@bx5974 ok, you were right, the docs should not have had this:
-----BOUNDARY
Content-Type: application/json
{"img_url":"http://bit.ly/ocrimage","engine":"tesseract"}
-----BOUNDARY
-----BOUNDARY
Content-Disposition: attachment;
Content-Type: image/png
filename="attachment.txt".
PNGDATA.........
-----BOUNDARY
I changed it to:
-----BOUNDARY
Content-Type: application/json
{"engine":"tesseract"}
-----BOUNDARY
-----BOUNDARY
Content-Disposition: attachment;
Content-Type: image/png
filename="attachment.txt".
PNGDATA.........
-----BOUNDARY
The img_url parameter has been removed.
Sorry, what you mean by raw data? can please you be clear?
how do you run a CURL command for local image file at /tmp/ocrimage.png
By raw data, I mean the actual data in the file without any processing or transformation. Base64 is a transformation of the data, so you don't want to do that.
Normally, file upload with curl is done like this:
curl -i -F name=test -F filedata=@localfile.jpg http://example.org/upload
However, OpenOCR expects a multipart/related MIME type, with both JSON and the file data. I don't know if it's even possible with curl. I googled it, and the closest thing I could find is this thread
You might want to ask on stack overflow or a curl support forum. If you figure it out, please post the solution to the ticket!
The other possibility is to look at the open-ocr-client and just compile it to a native binary and deploy it where you want to do upload via the command line.
I updated the README in open-ocr-client to make it easier to use this on the command line.
Also, I'll try to add a link to pre-built binaries to make it even easier. Which OS are you on?
@bx5974 There is a pre-built binary of open-ocr-client that will run on Linux available here:
Thank you, will give it a try and update.
Cool
Could you please help with the CURL command for open-ocr for a local image (than a remote URL) ?
I tried the reference API doc too, but it gave me no results.
Please help