下载文件或下载压缩包时,如何通过修改content-disposition中 filename 值的方式自定义文件名?
当前下载文件URL:http://localhost/dir/file.txt?download
使用以上URL下载文件时,默认文件名是 file.txt,因为服务端content-disposition = attachment; filename=file.txt; filename*=UTF-8''file.txt
如何通过修改URL链接参数的方式,修改服务端content-disposition中的filename值呢? 比如加入参数filename:http://localhost/dir/file.txt?download&filename=new_file_name.txt 让服务端content-disposition 值变成 attachment; filename=new_file_name.txt; filename*=UTF-8''new_file_name.txt
同理下载压缩包 http://localhost/tmp?zip&filename=new_file_name.zip 让服务端content-disposition 值变成 attachment; filename=new_file_name.zip; filename*=UTF-8''new_file_name.zip
可以实现么?
目前改成download[=filename]及zip[=filename]的形式,代码在unstable分支,之后会合并到主分支。
已发布到1.21.1