CppCMS
http_file.h
1 //
3 // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
4 //
5 // See accompanying file COPYING.TXT file for licensing details.
6 //
8 #ifndef CPPCMS_HTTP_FILE_H
9 #define CPPCMS_HTTP_FILE_H
10 
11 #include <cppcms/defs.h>
12 #include <cppcms/cstdint.h>
13 #include <booster/hold_ptr.h>
14 #include <booster/nowide/fstream.h>
15 #include <booster/noncopyable.h>
16 #include <sstream>
17 #include <fstream>
18 
19 namespace cppcms { namespace http {
20 
21  class request;
22 
32  class CPPCMS_API file : public booster::noncopyable {
33  public:
37  std::string name() const;
41  std::string mime() const;
45  std::string filename() const;
46 
51  std::istream &data();
52 
56  long long size();
57 
67  void save_to(std::string const &filename);
68 
70 
71  void name(std::string const &);
72  void mime(std::string const &);
73  void filename(std::string const &);
74  std::ostream &write_data();
75 
76  file();
77  ~file();
78 
79  void set_memory_limit(size_t size);
80  void set_temporary_directory(std::string const &dir);
81 
83 
84  private:
85  std::string name_;
86  std::string mime_;
87  std::string filename_;
88  size_t size_limit_;
89 
91  std::stringstream file_data_;
92  std::string tmp_file_name_;
93  std::string temporary_dir_;
94 
95  void move_to_file();
96  void save_by_copy(std::string const &file_name,std::istream &in);
97  void copy_stream(std::istream &in,std::ostream &out);
98 
99 
100  uint32_t saved_in_file_ : 1;
101  uint32_t removed_ : 1 ;
102  uint32_t reserverd_ : 30;
103 
104  struct impl_data; // for future use
106  friend class request;
107  };
108 
109 
110 } } //::cppcms::http
111 
112 
113 #endif
This class holds a uploaded file, it is generally fetched via widgets::file or via http::request::fil...
Definition: http_file.h:32
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15
basic_fstream< char > fstream
Definition: fstream.h:405
This class represents all information related to the HTTP/CGI request.
Definition: http_request.h:34