Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以上传和下载非图片文件 #160

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

qihaiyan
Copy link

能够支持非图片文件的上传和下载,
zimg.lua中做2处修改:

  1. format = 'jpeg' 改为 format = 'none'
  2. allowed_type改为 allowed_type = {'image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp', 'application/zip', 'application/pdf', 'application/msword', 'application/.docx', 'application/octet-stream'}
    上传时http头中加 zimg-filename:文件名 ,
    例如: zimg-filename:a.pdf
    下载非图片文件时需要加p=0参数
    上传示例:
    curl -H "Content-Type:application/octet-stream" -H "zimg-filename:a.pdf" --data-binary @a.pdf "http://localhost:4869"
    下载示例:
    curl "http://localhost:4869/5b43fa8518caa20cce5fea551228d7a3?p=0" > b.pdf
    在浏览器中输入文件对应的url地址后,会弹出下载框提示下载文件,默认的文件名就是zimg-filename指定的文件名。
    例如:
    http://localhost:4869/5b43fa8518caa20cce5fea551228d7a3?p=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants