class Poco::Net::FilePartStore

Overview

An implementation of PartSource for persisting parts (usually email attachment files) to the file system. Moreā€¦

#include <PartStore.h>

class FilePartStore: public Poco::Net::PartStore
{
public:
    // construction

    FilePartStore(
        const std::string& content,
        const std::string& mediaType,
        const std::string& filename = ""
        );

    // methods

    virtual
    std::istream&
    stream();

    virtual
    const std::string&
    filename() const;

    const std::string&
    path() const;
};

Inherited Members

public:
    // fields

    static const int UNKNOWN_CONTENT_LENGTH;

    // methods

    virtual
    std::istream&
    stream() = 0;

    virtual
    const std::string&
    filename() const;

    const std::string&
    mediaType() const;

    MessageHeader&
    headers();

    const MessageHeader&
    headers() const;

    virtual
    std::streamsize
    getContentLength() const;

Detailed Documentation

An implementation of PartSource for persisting parts (usually email attachment files) to the file system.

Construction

FilePartStore(
    const std::string& content,
    const std::string& mediaType,
    const std::string& filename = ""
    )

Creates the FilePartStore for the given MIME type.

For security purposes, attachment filename is NOT used to save file to the file system. A unique temporary file name is used to persist the file. The given filename parameter is the message part (attachment) filename (see filename()) only.

Throws an exception if the file cannot be opened.

Methods

virtual
std::istream&
stream()

Returns a file input stream for the given file.

virtual
const std::string&
filename() const

Returns the filename portion of the path.

This is the name under which the file is known to the user of this class (typically, MailMessage class). The real name of the file as saved to the filesystem can be obtained by calling path() member function.

const std::string&
path() const

Returns the full path to the file as saved to the file system.

For security reasons, file is not saved under the real file name (as specified by the user).