I am working on MQX 4.1, in this for some application i want to export .xml
file for the user,
For this Content Type set as "application/octet-stream", with these
settings Internet Explorer is opening .xml file directly without providing save
as option (Mozilla and Chrome Providing Save as Option).
For this additionally need to Content Disposition as "attachment"
so that IE will provide save as option.
Can anyone please guide how and where to set Content Disposition?
Hi,
I just reviewed the source code for the web_hvac demo in MQX 4.0.2. I can see that the USB file system possibility is still here. You can see that http_aliases array is actually used to define the other file system where the web server can find other files:
#if DEMOCFG_ENABLE_WEBSERVER
HTTPSRV_ALIAS http_aliases[] = {
{"/usb/", "c:\\ (file:///c://)"},
{NULL, NULL}
};
#endif
You also can see that this is used as one of the parameters for the creation of the web server:
params.alias_tbl = (HTTPSRV_ALIAS*)http_aliases;
You can access to those files by adding /usb/ to the end of the ip address in the web browser; just like this:
http: //192.168.1.202/usb/index.html
Using this feature I think you can get the access to the content.
Have a great day,
Regards
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Sol,
Thanks for the Information....
Problem is I am not facing issue regarding file access...
Main issue is insted of save as option, .xml file is getting open in Internet Exlorer itself...
For this we need to set Contenet Disposition.....
I need help about how and where we can set content disposition?
Thanks for the help,
Shreyas
Hi,
If you need to add/modify any MIME type in HTTPSRV you have to do following:
typedef enum httpsrv_content_type
{
HTTPSRV_CONTENT_TYPE_OCTETSTREAM = 1,
HTTPSRV_CONTENT_TYPE_PLAIN,
HTTPSRV_CONTENT_TYPE_HTML,
HTTPSRV_CONTENT_TYPE_CSS,
HTTPSRV_CONTENT_TYPE_GIF,
HTTPSRV_CONTENT_TYPE_JPG,
HTTPSRV_CONTENT_TYPE_PNG,
HTTPSRV_CONTENT_TYPE_SVG,
HTTPSRV_CONTENT_TYPE_JS,
HTTPSRV_CONTENT_TYPE_ZIP,
HTTPSRV_CONTENT_TYPE_PDF,
HTTPSRV_CONTENT_TYPE_XML,
} HTTPSRV_CONTENT_TYPE;
static const httpsrv_table_row content_type[] = {
{ HTTPSRV_CONTENT_TYPE_PLAIN, "text/plain" },
{ HTTPSRV_CONTENT_TYPE_HTML, "text/html" },
{ HTTPSRV_CONTENT_TYPE_CSS, "text/css" },
{ HTTPSRV_CONTENT_TYPE_GIF, "image/gif" },
{ HTTPSRV_CONTENT_TYPE_JPG, "image/jpeg" },
{ HTTPSRV_CONTENT_TYPE_PNG, "image/png" },
{ HTTPSRV_CONTENT_TYPE_SVG, "image/svg+xml"},
{ HTTPSRV_CONTENT_TYPE_JS, "application/javascript" },
{ HTTPSRV_CONTENT_TYPE_ZIP, "application/zip" },
{ HTTPSRV_CONTENT_TYPE_XML, "application/xml" },
{ HTTPSRV_CONTENT_TYPE_PDF, "application/pdf" },
{ HTTPSRV_CONTENT_TYPE_OCTETSTREAM, "application/octet-stream" },
{ 0, 0 }
};
static httpsrv_content_table_row content_tbl[] = {
/* Size, extension, MIME type, Cache? */
{sizeof("js")-1 , "js", HTTPSRV_CONTENT_TYPE_JS, TRUE},
{sizeof("css")-1, "css", HTTPSRV_CONTENT_TYPE_CSS, TRUE},
{sizeof("gif")-1, "gif", HTTPSRV_CONTENT_TYPE_GIF, TRUE},
{sizeof("htm")-1, "htm", HTTPSRV_CONTENT_TYPE_HTML, TRUE},
{sizeof("jpg")-1, "jpg", HTTPSRV_CONTENT_TYPE_JPG, TRUE},
{sizeof("pdf")-1, "pdf", HTTPSRV_CONTENT_TYPE_PDF, FALSE},
{sizeof("png")-1, "png", HTTPSRV_CONTENT_TYPE_PNG, TRUE},
{sizeof("svg")-1, "svg", HTTPSRV_CONTENT_TYPE_SVG, TRUE},
{sizeof("txt")-1, "txt", HTTPSRV_CONTENT_TYPE_PLAIN, FALSE},
{sizeof("xml")-1, "xml", HTTPSRV_CONTENT_TYPE_XML, FALSE},
{sizeof("zip")-1, "zip", HTTPSRV_CONTENT_TYPE_ZIP, FALSE},
{sizeof("html")-1, "html", HTTPSRV_CONTENT_TYPE_HTML, TRUE},
{sizeof("shtm")-1, "shtm", HTTPSRV_CONTENT_TYPE_HTML, FALSE},
{sizeof("shtml")-1, "shtml", HTTPSRV_CONTENT_TYPE_HTML, FALSE},
/* Following row MUST have length set to zero so we have proper array termination */
{0, "", HTTPSRV_CONTENT_TYPE_OCTETSTREAM, FALSE}
};