文章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模块的配置请见下篇文章。

你可能感兴趣的:(nginx,Module,upload,File,encoding,methods)