Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Of course. The documents of zimg is written in Chinese so you don't know how to use.

1. Using curl and multiform way can post file to zimg and will return a html result:

curl -F "blob=@testup.jpeg;type=image/jpeg" "http://127.0.0.1:4869/upload"

If you don't like upload files via multiform way, you can use raw post way. Use this command to upload image via raw post:

curl -H "Content-Type:jpeg" --data-binary @testup.jpeg "http://127.0.0.1:4869/upload"

You need tell zimg a header "Content-Type", the value is the type of image. This way will get a json result and the error message is in the table below:

{"ret":false,"error":{"code":0,"message":"Internal error."}} {"ret":false,"error":{"code":1,"message":"File type not support."}} {"ret":false,"error":{"code":2,"message":"Request method error."}} {"ret":false,"error":{"code":3,"message":"Access error."}} {"ret":false,"error":{"code":4,"message":"Request body parse error."}} {"ret":false,"error":{"code":5,"message":"Content-Length error."}} {"ret":false,"error":{"code":6,"message":"Content-Type error."}} {"ret":false,"error":{"code":7,"message":"File too large."}}

2. Upload and download access control. Just modify conf file like this:

upload_rule = 'allow 127.0.0.1;allow xx.xx.xxx.xxx/xx' download_rule = 'allow all'

The conf rule is like nginx.

3. Sorry for missing English documents.



Nice! Thanks. A perfect fit for my current project.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: