buaazp / zimg

A lightweight and high performance image storage and processing system.
http://zimg.buaa.us
BSD 3-Clause "New" or "Revised" License
2.69k stars 402 forks source link

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

Open qihaiyan opened 8 years ago

qihaiyan commented 8 years ago

能够支持非图片文件的上传和下载, 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