FilePart
FilePart
#include <icy/http/form.h>Inherits:
FormPart
Form part backed by a file on disk.
Public Methods
| Return | Name | Description |
|---|---|---|
FilePart | Creates the FilePart for the given path. | |
FilePart | Creates the FilePart for the given path and MIME type. | |
FilePart | Creates the FilePart for the given path and MIME type. The given filename is used as part filename (see filename()) only. | |
~FilePart virtual | Destroys the FilePart. | |
void | open virtual | Opens the file for reading. |
void | reset virtual | Resets the file stream to the beginning and clears initial-write state. |
bool | writeChunk virtual | Writes the next chunk of the file to the FormWriter. |
void | write virtual | Writes the entire file content to the FormWriter. |
void | write virtual | Writes the entire file content to an output stream (used for content-length calculation). |
const std::string & | filename const | Returns the filename component of the file path (not the full path). |
std::ifstream & | stream | Returns a reference to the underlying file input stream. |
uint64_t | length virtual const | Returns the total file size in bytes. |
FilePart
FilePart(const std::string & path)Creates the FilePart for the given path.
The MIME type is set to application/octet-stream.
Throws an FileException if the file cannot be opened.
FilePart
FilePart(const std::string & path, const std::string & contentType)Creates the FilePart for the given path and MIME type.
Throws an FileException if the file cannot be opened.
FilePart
FilePart(const std::string & path, const std::string & filename, const std::string & contentType)Creates the FilePart for the given path and MIME type. The given filename is used as part filename (see filename()) only.
Throws an FileException if the file cannot be opened.
~FilePart
virtual
virtual ~FilePart()Destroys the FilePart.
open
virtual
virtual void open()Opens the file for reading.
Exceptions
std::runtime_errorif the file cannot be opened.
reset
virtual
virtual void reset()Resets the file stream to the beginning and clears initial-write state.
writeChunk
virtual
virtual bool writeChunk(FormWriter & writer)Writes the next chunk of the file to the FormWriter.
Parameters
writerThe FormWriter to send the chunk through.
Returns
true if more data remains; false when the file is fully sent.
write
virtual
virtual void write(FormWriter & writer)Writes the entire file content to the FormWriter.
Parameters
writerThe FormWriter to send data through.
write
virtual
virtual void write(std::ostream & ostr)Writes the entire file content to an output stream (used for content-length calculation).
Parameters
ostrOutput stream to write to.
filename
const
const std::string & filename() constReturns the filename component of the file path (not the full path).
stream
std::ifstream & stream()Returns a reference to the underlying file input stream.
length
virtual const
virtual uint64_t length() constReturns the total file size in bytes.
Protected Attributes
_path
std::string _path_filename
std::string _filename_istr
std::ifstream _istr_fileSize
uint64_t _fileSize