cppcms::http::file Class Reference

This class holds a uploaded file, it is generally fetched via widgets::file or via http::request::files. More...

`#include <cppcms/http_file.h>`

Inheritance diagram for cppcms::http::file:

## Public Member Functions

std::string | name () const
std::string | mime () const
std::string | filename () const
std::istream & | data ()
long long | size ()
void | save_to (std::string const &filename)

## Friends

class | request

## Detailed Description

This class holds a uploaded file, it is generally fetched via widgets::file or via 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 widgets::file that allows to perform numerous checks on the file data.

## Member Function Documentation

std::istream& cppcms::http::file::data | ( |  | ) |

Get std::istream on the data, please note, you need to call data().seekg(0) when using this stream first time.

std::string cppcms::http::file::filename | ( |  | ) | const

Get the filename as it was sent by the browser.

std::string cppcms::http::file::mime | ( |  | ) | const

Get the content-type of the file as it was sent by the browser.

std::string cppcms::http::file::name | ( |  | ) | const

Get the name of the POST field (i.e. <input name="value" ...>)

void cppcms::http::file::save_to | ( | std::string const & | filename | ) |

Save file to file named filename. Throws cppcms_error in case of failure.

Notes:

- 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
- Under Win32 filename should be UTF-8 string

long long cppcms::http::file::size | ( |  | ) |

Get the size of the file.

The documentation for this class was generated from the following file:

- cppcms/http_file.h