http_file.h
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
#ifndef CPPCMS_HTTP_FILE_H
#define CPPCMS_HTTP_FILE_H
#include <cppcms/defs.h>
#include <cppcms/cstdint.h>
#include <booster/hold_ptr.h>
#include <booster/nowide/fstream.h>
#include <booster/noncopyable.h>
#include <sstream>
#include <fstream>
namespace cppcms { namespace http {
class request;
class CPPCMS_API file : public booster::noncopyable {
public:
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);
void name(std::string const &);
void mime(std::string const &);
void filename(std::string const &);
std::ostream &write_data();
file();
~file();
void set_memory_limit(size_t size);
void set_temporary_directory(std::string const &dir);
private:
std::string name_;
std::string mime_;
std::string filename_;
size_t size_limit_;
booster::nowide::fstream file_;
std::stringstream file_data_;
std::string tmp_file_name_;
std::string temporary_dir_;
void move_to_file();
void save_by_copy(std::string const &file_name,std::istream &in);
void copy_stream(std::istream &in,std::ostream &out);
uint32_t saved_in_file_ : 1;
uint32_t removed_ : 1 ;
uint32_t reserverd_ : 30;
struct impl_data; // for future use
booster::hold_ptr<impl_data> d;
friend class request;
};
} } //::cppcms::http
#endif
booster::hold_ptr< impl_data >
cppcms::http::file
This class holds a uploaded file, it is generally fetched via widgets::file or via http::request::fil...
Definition: http_file.h:32
booster::noncopyable
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15
booster::nowide::fstream
basic_fstream< char > fstream
Definition: fstream.h:405
cppcms::http::request
This class represents all information related to the HTTP/CGI request.
Definition: http_request.h:34