aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2019-11-19 19:57:16 +0300
committerAleksey Veresov <aleksey@veresov.pro>2019-11-19 19:57:16 +0300
commit0f6943feff48e92b071726abcf83070d8a529a41 (patch)
tree6e8f89d06f85b66083a8efa00d137efaca2941fa /examples
parent03c27c8542d23a5e4072f0c080c396ce608c1d50 (diff)
downloadmagi-0f6943feff48e92b071726abcf83070d8a529a41.tar
magi-0f6943feff48e92b071726abcf83070d8a529a41.tar.xz
magi-0f6943feff48e92b071726abcf83070d8a529a41.zip
.
Diffstat (limited to 'examples')
-rw-r--r--examples/upload.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/examples/upload.c b/examples/upload.c
index 95c7f87..2ef8bc5 100644
--- a/examples/upload.c
+++ b/examples/upload.c
@@ -11,24 +11,19 @@ void tempfile_callback(struct magi_file * file,
int len,
void * _)
{
- static FILE * file = 0;
- if (!strcmp(field->name, "data")) {
- if (!file) {
- remove(field->name);
- file = fopen(field->name, "wb");
+ if (!strcmp(file->param_name, "data")) {
+ static FILE * f = 0;
+ if (!f) {
+ remove(file->param_name);
+ f = fopen(file->param_name, "wb");
}
if (len) {
- fwrite(buffer, 1, len, file);
+ fwrite(buffer, 1, len, f);
}
- if (len < magi_parse_multipart_callback_size) {
- fclose(file);
- file = 0;
+ if (len < magi_file_callback_portion_max) {
+ fclose(f);
+ f = 0;
}
- } else if (len) {
- field->data = realloc(field->data, field->len + len + 1);
- memcpy(field->data + field->len, buffer, len);
- field->len += len;
- field->data[field->len] = 0;
}
}