forked from fdintino/nginx-upload-module
/
ngx_upload_discard_filter_module.c
101 lines (80 loc) · 3.47 KB
/
ngx_upload_discard_filter_module.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (C) 2008 Valery Kholodkov
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#include <ngx_http_upload.h>
static ngx_int_t ngx_upload_discard_start_handler(ngx_http_upload_ctx_t *u);
static void ngx_upload_discard_finish_handler(ngx_http_upload_ctx_t *u);
static void ngx_upload_discard_abort_handler(ngx_http_upload_ctx_t *u);
static ngx_int_t ngx_upload_discard_data_handler(ngx_http_upload_ctx_t *u,
ngx_chain_t *chain);
static char *ngx_upload_discard_command(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static ngx_upload_content_filter_t /* {{{ */
ngx_upload_discard_content_filter = {
ngx_upload_discard_start_handler,
ngx_upload_discard_finish_handler,
ngx_upload_discard_abort_handler,
ngx_upload_discard_data_handler
} /* }}} */;
static ngx_command_t ngx_upload_discard_filter_commands[] = { /* {{{ */
/*
* Discards uploaded file
*/
{ ngx_string("upload_discard"),
NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
ngx_upload_discard_command,
NGX_HTTP_LOC_CONF_OFFSET,
0,
NULL },
ngx_null_command
}; /* }}} */
ngx_http_module_t ngx_upload_discard_filter_module_ctx = { /* {{{ */
NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
NULL, /* init main configuration */
NULL, /* create server configuration */
NULL, /* merge server configuration */
NULL, /* create location configuration */
NULL /* merge location configuration */
}; /* }}} */
ngx_module_t ngx_upload_discard_filter_module = { /* {{{ */
NGX_MODULE_V1,
&ngx_upload_discard_filter_module_ctx, /* module context */
ngx_upload_discard_filter_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
NULL, /* init master */
NULL, /* init module */
NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
NULL, /* exit master */
NGX_MODULE_V1_PADDING
}; /* }}} */
static char * /* {{{ ngx_upload_discard_command */
ngx_upload_discard_command(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_upload_loc_conf_t *ulcf;
ulcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_upload_module);
if(ngx_http_upload_add_filter(ulcf, &ngx_upload_discard_content_filter, cf->pool) != NGX_OK) {
return NGX_CONF_ERROR;
}
return NGX_CONF_OK;
} /* }}} */
static ngx_int_t /* {{{ ngx_upload_discard_start_handler */
ngx_upload_discard_start_handler(ngx_http_upload_ctx_t *u) {
return NGX_OK;
} /* }}} */
static void /* {{{ ngx_upload_discard_finish_handler */
ngx_upload_discard_finish_handler(ngx_http_upload_ctx_t *u) {
} /* }}} */
static void /* {{{ ngx_upload_discard_abort_handler */
ngx_upload_discard_abort_handler(ngx_http_upload_ctx_t *u) {
} /* }}} */
static ngx_int_t /* {{{ ngx_upload_discard_data_handler */
ngx_upload_discard_data_handler(ngx_http_upload_ctx_t *u, ngx_chain_t *chain) {
return NGX_OK;
} /* }}} */