文章15:Nginx upload 模块(一)

原文http://www.grid.net.ru/nginx/upload.en.html 译者yankai0219,欢迎转载,转载请注明出处 http://blog.csdn.net/yankai0219/article/details/8085725

Upload Module

A module for nginx web server for handling file uploads using multipart/form-data encoding (RFC 1867) and resumable uploads according to this protocol.

upload模块是nginx网络服务器的一个模块,该模块使用multipart/form-data 编码方式上传文件,并且通过该协议可以重新获取上传文件。

Description

The module parses request body storing all files being uploaded to a directory specified by upload_store directive. The files are then being stripped from body and altered request is then passed to a location specified by upload_pass directive, thus allowing arbitrary handling of uploaded files. Each of file fields are being replaced by a set of fields specified by upload_set_form_field directive. The content of each uploaded file then could be read from a file specified by $upload_tmp_path variable or the file could be simply moved to ultimate destination. Removal of output files is controlled by directive upload_cleanup. If a request has a method other than POST, the module returns error 405 (Method not allowed). Requests with such methods could be processed in alternative location via error_page directive.

概述:

upload模块解析存储所有文件的请求体,所有文件被上传到upload_store指定的目录中。然后文件从body中被剥离,接着被传送到upload_pass指定的location中,因此允许任意处理上传文件。每个文件的字段被一组由upload_set_form_field指定的字段取代。之后,每个上传文件的内容可以从变量$upload_tmp_path指定的文件中读取,或者文件直接简单的保存到最终目的地。输出文件的删除由指令upload_cleanup指定。如果一个请求不是POST请求,那么upload模块会返回405错误。其他方法的请求处理可以通过指令error_page进行处理。

译者注:通过我的查证,可以发现upload_pass @xxx,即传到location @xxx中的ngx_request_t r中的请求体不包含文件信息,即原文中The files are then being stripped from body的含义所在。

指令部分就不一一进行翻译。对于upload模块的配置请见下篇文章。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值