...
Each HTTPc_MULTIPART_FILE
objects contained in a table form must have set up a hook function pointer with the parameter OnFileTx
. The HTTPc transmit buffer pointer and the length available inside are passed as argument to allow the hook function to copy the data file directly inside the HTTPc buffer.
Prototype
Code Block |
---|
CPU_BOOLEAN HTTPc_FormMultipartFileHook (HTTPc_CONN_OBJ *p_conn_obj,
HTTPc_REQ_OBJ *p_req_obj,
HTTPc_MULTIPART_FILE *p_file_obj,
CPU_CHAR *p_buf,
CPU_INT16U buf_len,
CPU_INT16U *p_len_wr); |
Arguments
p_conn_obj
Pointer to the current HTTPc Connection Object.
...
Notes / Warnings
None.
Example Template
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
static CPU_BOOLEAN HTTPc_FormMultipartFileHook (HTTPc_CONN_OBJ *p_conn_obj,
HTTPc_REQ_OBJ *p_req_obj,
HTTPc_MULTIPART_FILE *p_file_obj,
CPU_CHAR *p_buf,
CPU_INT16U buf_len,
CPU_INT16U *p_len_wr);
{
FS_FILE *p_file;
FS_FLAGS fs_flags;
CPU_SIZE_T file_rem;
CPU_SIZE_T size;
CPU_SIZE_T size_rd;
CPU_BOOLEAN is_open;
CPU_BOOLEAN finish;
FS_ERR err_fs;
finish = DEF_YES;
is_open = FSFile_IsOpen("index.html",
&fs_flags,
&err_fs);
if (err_fs != FS_ERR_NONE) {
return (finish);
}
if (is_open == DEF_NO) {
fs_flags = 0;
DEF_BIT_SET(fs_flags, FS_FILE_ACCESS_MODE_RD);
DEF_BIT_SET(fs_flags, FS_FILE_ACCESS_MODE_CREATE);
p_file = FSFile_Open("index.html",
fs_flags,
&err_fs);
if (err_fs != FS_ERR_NONE) {
return (finish);
}
p_req->UserDataPtr = (void *)p_file;
} else {
p_file = (FS_FILE *)p_req->UserDataPtr;
}
file_rem = p_file->Size - p_file->Pos;
if (file_rem <= 0) {
*p_len_wr = 0;
finish = DEF_YES;
FSFile_Close(p_file, &err_fs);
goto exit;
}
size = DEF_MIN(file_rem, buf_len);
size_rd = FSFile_Rd(p_file, p_buf, size, &err_fs);
if (err_fs != FS_ERR_NONE) {
return (finish);
}
*p_len_wr = size_rd;
finish = DEF_NO;
exit:
return (finish);
} |
Info |
---|
This code uses the µC/FS File System for example purposes. |
...