\section{cppcms\+:\+:http\+:\+:file Class Reference}
\label{classcppcms_1_1http_1_1file}\index{cppcms\+::http\+::file@{cppcms\+::http\+::file}}


This class holds a uploaded file, it is generally fetched via \doxyref{widgets\+::file}{p.}{classcppcms_1_1widgets_1_1file} or via {\tt http\+::request\+::files}.  




{\ttfamily \#include $<$cppcms/http\+\_\+file.\+h$>$}

Inheritance diagram for cppcms\+:\+:http\+:\+:file\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classcppcms_1_1http_1_1file}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
std\+::string {\bf name} () const 
\item 
std\+::string {\bf mime} () const 
\item 
bool {\bf has\+\_\+mime} () const 
\item 
std\+::string {\bf filename} () const 
\item 
std\+::istream \& {\bf data} ()
\item 
long long {\bf size} ()
\item 
void {\bf output\+\_\+file} (std\+::string const \&{\bf name}, bool is\+\_\+temporary=false)
\item 
void {\bf make\+\_\+permanent} ()
\item 
int {\bf close} ()
\item 
void {\bf save\+\_\+to} (std\+::string const \&{\bf filename})
\item 
void {\bf set\+\_\+memory\+\_\+limit} (size\+\_\+t {\bf size})
\item 
void {\bf set\+\_\+temporary\+\_\+directory} (std\+::string const \&dir)
\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
class {\bfseries request}\label{classcppcms_1_1http_1_1file_a85b2d00ed5d8672f7dbb26f19a0b6123}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
This class holds a uploaded file, it is generally fetched via \doxyref{widgets\+::file}{p.}{classcppcms_1_1widgets_1_1file} or via {\tt http\+::request\+::files}. 

It provides full information about uploaded data as it was send by browser and allows to read the file via std\+::istream seek-\/able interface or save to the file system

Note\+: this class does not perform any validations, for checking the data use \doxyref{widgets\+::file}{p.}{classcppcms_1_1widgets_1_1file} that allows to perform numerous checks on the file data. 

\subsection{Member Function Documentation}
\index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!close@{close}}
\index{close@{close}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{close()}]{\setlength{\rightskip}{0pt plus 5cm}int cppcms\+::http\+::file\+::close (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_a81bff76b6569f661b18f07dae57025c7}
Close the file if it is still open, if the file temporary it is deleted, the the file in memory its content is removed, \doxyref{data()}{p.}{classcppcms_1_1http_1_1file_a3a95bc7fefe80a75bc098baa3ad8c400} would return non-\/usable stream

Returns 0 in case of sucess and -\/1 in case of failure

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!data@{data}}
\index{data@{data}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{data()}]{\setlength{\rightskip}{0pt plus 5cm}std\+::istream\& cppcms\+::http\+::file\+::data (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_a3a95bc7fefe80a75bc098baa3ad8c400}
Get std\+::istream on the data, please note, you need to call \doxyref{data()}{p.}{classcppcms_1_1http_1_1file_a3a95bc7fefe80a75bc098baa3ad8c400}.seekg(0) when using this stream first time. \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!filename@{filename}}
\index{filename@{filename}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{filename() const }]{\setlength{\rightskip}{0pt plus 5cm}std\+::string cppcms\+::http\+::file\+::filename (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}\label{classcppcms_1_1http_1_1file_aec7aaa5ab4f57aada988507d5d299f6f}
Get the filename as it was sent by the browser. \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!has\+\_\+mime@{has\+\_\+mime}}
\index{has\+\_\+mime@{has\+\_\+mime}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{has\+\_\+mime() const }]{\setlength{\rightskip}{0pt plus 5cm}bool cppcms\+::http\+::file\+::has\+\_\+mime (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}\label{classcppcms_1_1http_1_1file_a6f94cc6fc4068828a74fe8110cc295b1}
Returns true if content type defined

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!make\+\_\+permanent@{make\+\_\+permanent}}
\index{make\+\_\+permanent@{make\+\_\+permanent}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{make\+\_\+permanent()}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::file\+::make\+\_\+permanent (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_a10a75d543175cd0a69bbbc44049efc26}
Make sure that file created by output\+\_\+file member function is not removed in destructor

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!mime@{mime}}
\index{mime@{mime}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{mime() const }]{\setlength{\rightskip}{0pt plus 5cm}std\+::string cppcms\+::http\+::file\+::mime (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}\label{classcppcms_1_1http_1_1file_ab8d8de07a1bf0ce904737dfe53a017bd}
Get the content-\/type of the file as it was sent by the browser. \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!name@{name}}
\index{name@{name}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{name() const }]{\setlength{\rightskip}{0pt plus 5cm}std\+::string cppcms\+::http\+::file\+::name (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}\label{classcppcms_1_1http_1_1file_ab2691618c7312d598a080d60410bad00}
Get the name of the P\+O\+ST field (i.\+e. $<$input name=\char`\"{}value\char`\"{} ...$>$) \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!output\+\_\+file@{output\+\_\+file}}
\index{output\+\_\+file@{output\+\_\+file}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{output\+\_\+file(std\+::string const \&name, bool is\+\_\+temporary=false)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::file\+::output\+\_\+file (
\begin{DoxyParamCaption}
\item[{std\+::string const \&}]{name, }
\item[{bool}]{is\+\_\+temporary = {\ttfamily false}}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_a9fcb51feca28d1ad113552f63ab82896}
Specify the path to the output file, note if is\+\_\+temporary is true than the file would be deleted on \doxyref{cppcms\+::http\+::file}{p.}{classcppcms_1_1http_1_1file} destruction, unless save\+\_\+to is called, otherwise it would remain persistent

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!save\+\_\+to@{save\+\_\+to}}
\index{save\+\_\+to@{save\+\_\+to}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{save\+\_\+to(std\+::string const \&filename)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::file\+::save\+\_\+to (
\begin{DoxyParamCaption}
\item[{std\+::string const \&}]{filename}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_a981a2325266c685788f8e241f2154308}
Save file to file named {\itshape filename}. Throws \doxyref{cppcms\+\_\+error}{p.}{classcppcms_1_1cppcms__error} in case of failure.

Notes\+:


\begin{DoxyItemize}
\item this function maybe more efficient then just reading the stream and writing it to newly created file, as in case of big files, it would try to move it over the file system
\item Under Win32 {\itshape filename} should be U\+T\+F-\/8 string 
\end{DoxyItemize}\index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!set\+\_\+memory\+\_\+limit@{set\+\_\+memory\+\_\+limit}}
\index{set\+\_\+memory\+\_\+limit@{set\+\_\+memory\+\_\+limit}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{set\+\_\+memory\+\_\+limit(size\+\_\+t size)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::file\+::set\+\_\+memory\+\_\+limit (
\begin{DoxyParamCaption}
\item[{size\+\_\+t}]{size}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_a11196e4f597b326da3623d78316e4bb9}
Set the maximal size of file that would be stored in memory instead of file system

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!set\+\_\+temporary\+\_\+directory@{set\+\_\+temporary\+\_\+directory}}
\index{set\+\_\+temporary\+\_\+directory@{set\+\_\+temporary\+\_\+directory}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{set\+\_\+temporary\+\_\+directory(std\+::string const \&dir)}]{\setlength{\rightskip}{0pt plus 5cm}void cppcms\+::http\+::file\+::set\+\_\+temporary\+\_\+directory (
\begin{DoxyParamCaption}
\item[{std\+::string const \&}]{dir}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_a0e3eb2d67f37ef413915d43f166ec6fe}
Set the temporary directory where uploaded files are created

\doxyref{New in Cpp\+C\+MS 1.\+2}{p.}{v1_2} \index{cppcms\+::http\+::file@{cppcms\+::http\+::file}!size@{size}}
\index{size@{size}!cppcms\+::http\+::file@{cppcms\+::http\+::file}}
\subsubsection[{size()}]{\setlength{\rightskip}{0pt plus 5cm}long long cppcms\+::http\+::file\+::size (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classcppcms_1_1http_1_1file_aee3dac0ba0afc1128c0a20b72c998238}
Get the size of the file. 

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
cppcms/http\+\_\+file.\+h\end{DoxyCompactItemize}
