Home
HTTP module

FilePart

Form part backed by a file on disk.

FilePart

#include <icy/http/form.h>
class FilePart

Defined in src/http/include/icy/http/form.h:236

Inherits: FormPart

Form part backed by a file on disk.

List of all members

NameKindOwner
FilePartfunctionDeclared here
FilePartfunctionDeclared here
FilePartfunctionDeclared here
~FilePartfunctionDeclared here
openfunctionDeclared here
resetfunctionDeclared here
writeChunkfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
filenamefunctionDeclared here
streamfunctionDeclared here
lengthfunctionDeclared here
_pathvariableDeclared here
_filenamevariableDeclared here
_istrvariableDeclared here
_fileSizevariableDeclared here
FormPartfunctionInherited from FormPart
~FormPartfunctionInherited from FormPart
resetfunctionInherited from FormPart
writeChunkfunctionInherited from FormPart
writefunctionInherited from FormPart
writefunctionInherited from FormPart
headersfunctionInherited from FormPart
initialWritefunctionInherited from FormPart
contentTypefunctionInherited from FormPart
lengthfunctionInherited from FormPart
_contentTypevariableInherited from FormPart
_lengthvariableInherited from FormPart
_headersvariableInherited from FormPart
_initialWritevariableInherited from FormPart

Inherited from FormPart

KindNameDescription
functionFormPartCreates the FormPart with the given MIME content type.
function~FormPart virtualDestroys the FormPart.
functionreset virtualResets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length.
functionwriteChunk virtualWrites the next chunk of data to the FormWriter.
functionwrite virtualWrites the entire part data to the FormWriter in one call.
functionwrite virtualWrites the entire part data to an output stream (used for content-length calculation).
functionheadersReturns the extra MIME headers for this part (e.g. Content-Disposition).
functioninitialWrite virtual constReturns true if this is the first write call since construction or reset().
functioncontentType constReturns the MIME content type for this part.
functionlength virtual constReturns the total byte length of the part data.
variable_contentType
variable_length
variable_headers
variable_initialWrite

Public Methods

ReturnNameDescription
FilePartCreates the FilePart for the given path.
FilePartCreates the FilePart for the given path and MIME type.
FilePartCreates the FilePart for the given path and MIME type. The given filename is used as part filename (see filename()) only.
~FilePart virtualDestroys the FilePart.
voidopen virtualOpens the file for reading.
voidreset virtual overrideResets the file stream to the beginning and clears initial-write state.
boolwriteChunk virtual overrideWrites the next chunk of the file to the FormWriter.
voidwrite virtual overrideWrites the entire file content to the FormWriter.
voidwrite virtual overrideWrites the entire file content to an output stream (used for content-length calculation).
const std::string &filename constReturns the filename component of the file path (not the full path).
std::ifstream &streamReturns a reference to the underlying file input stream.
uint64_tlength virtual const overrideReturns the total file size in bytes.

FilePart

FilePart(const std::string & path)

Defined in src/http/include/icy/http/form.h:244

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)

Defined in src/http/include/icy/http/form.h:250

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)

Defined in src/http/include/icy/http/form.h:257

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()

Defined in src/http/include/icy/http/form.h:261

Destroys the FilePart.


open

virtual

virtual void open()

Defined in src/http/include/icy/http/form.h:265

Opens the file for reading.

Exceptions

  • std::runtime_error if the file cannot be opened.

reset

virtual override

virtual void reset() override

Defined in src/http/include/icy/http/form.h:268

Resets the file stream to the beginning and clears initial-write state.

Reimplements

writeChunk

virtual override

virtual bool writeChunk(FormWriter & writer) override

Defined in src/http/include/icy/http/form.h:273

Writes the next chunk of the file to the FormWriter.

Parameters

  • writer The FormWriter to send the chunk through.

Returns

true if more data remains; false when the file is fully sent.

Reimplements

write

virtual override

virtual void write(FormWriter & writer) override

Defined in src/http/include/icy/http/form.h:277

Writes the entire file content to the FormWriter.

Parameters

Reimplements

write

virtual override

virtual void write(std::ostream & ostr) override

Defined in src/http/include/icy/http/form.h:281

Writes the entire file content to an output stream (used for content-length calculation).

Parameters

  • ostr Output stream to write to.
Reimplements

filename

const

const std::string & filename() const

Defined in src/http/include/icy/http/form.h:284

Returns the filename component of the file path (not the full path).


stream

std::ifstream & stream()

Defined in src/http/include/icy/http/form.h:287

Returns a reference to the underlying file input stream.


length

virtual const override

virtual uint64_t length() const override

Defined in src/http/include/icy/http/form.h:290

Returns the total file size in bytes.

Reimplements

Protected Attributes

ReturnNameDescription
std::string_path
std::string_filename
std::ifstream_istr
uint64_t_fileSize

_path

std::string _path

Defined in src/http/include/icy/http/form.h:293


_filename

std::string _filename

Defined in src/http/include/icy/http/form.h:294


_istr

std::ifstream _istr

Defined in src/http/include/icy/http/form.h:295


_fileSize

uint64_t _fileSize

Defined in src/http/include/icy/http/form.h:296