Class FilePart

    • Field Detail

      • DEFAULT_CONTENT_TYPE

        public static final java.lang.String DEFAULT_CONTENT_TYPE
        Default content encoding of file attachments.
        See Also:
        Constant Field Values
      • DEFAULT_CHARSET

        public static final java.lang.String DEFAULT_CHARSET
        Default charset of file attachments.
        See Also:
        Constant Field Values
      • DEFAULT_TRANSFER_ENCODING

        public static final java.lang.String DEFAULT_TRANSFER_ENCODING
        Default transfer encoding of file attachments.
        See Also:
        Constant Field Values
      • FILE_NAME

        protected static final java.lang.String FILE_NAME
        Attachment's file name
        See Also:
        Constant Field Values
    • Constructor Detail

      • FilePart

        public FilePart​(java.lang.String name,
                        PartSource partSource,
                        java.lang.String contentType,
                        java.lang.String charset)
        FilePart Constructor.
        Parameters:
        name - the name for this part
        partSource - the source for this part
        contentType - the content type for this part, if null the default is used
        charset - the charset encoding for this part, if null the default is used
      • FilePart

        public FilePart​(java.lang.String name,
                        PartSource partSource)
        FilePart Constructor.
        Parameters:
        name - the name for this part
        partSource - the source for this part
      • FilePart

        public FilePart​(java.lang.String name,
                        java.io.File file)
                 throws java.io.FileNotFoundException
        FilePart Constructor.
        Parameters:
        name - the name of the file part
        file - the file to post
        Throws:
        java.io.FileNotFoundException - if the file is not a normal file or if it is not readable.
      • FilePart

        public FilePart​(java.lang.String name,
                        java.io.File file,
                        java.lang.String contentType,
                        java.lang.String charset)
                 throws java.io.FileNotFoundException
        FilePart Constructor.
        Parameters:
        name - the name of the file part
        file - the file to post
        contentType - the content type for this part, if null the default is used
        charset - the charset encoding for this part, if null the default is used
        Throws:
        java.io.FileNotFoundException - if the file is not a normal file or if it is not readable.
      • FilePart

        public FilePart​(java.lang.String name,
                        java.lang.String fileName,
                        java.io.File file)
                 throws java.io.FileNotFoundException
        FilePart Constructor.
        Parameters:
        name - the name of the file part
        fileName - the file name
        file - the file to post
        Throws:
        java.io.FileNotFoundException - if the file is not a normal file or if it is not readable.
      • FilePart

        public FilePart​(java.lang.String name,
                        java.lang.String fileName,
                        java.io.File file,
                        java.lang.String contentType,
                        java.lang.String charset)
                 throws java.io.FileNotFoundException
        FilePart Constructor.
        Parameters:
        name - the name of the file part
        fileName - the file name
        file - the file to post
        contentType - the content type for this part, if null the default is used
        charset - the charset encoding for this part, if null the default is used
        Throws:
        java.io.FileNotFoundException - if the file is not a normal file or if it is not readable.
    • Method Detail

      • sendDispositionHeader

        protected void sendDispositionHeader​(java.io.OutputStream out)
                                      throws java.io.IOException
        Write the disposition header to the output stream
        Overrides:
        sendDispositionHeader in class Part
        Parameters:
        out - The output stream
        Throws:
        java.io.IOException - If an IO problem occurs
        See Also:
        Part.sendDispositionHeader(OutputStream)
      • sendData

        protected void sendData​(java.io.OutputStream out)
                         throws java.io.IOException
        Write the data in "source" to the specified stream.
        Specified by:
        sendData in class Part
        Parameters:
        out - The output stream.
        Throws:
        java.io.IOException - if an IO problem occurs.
        See Also:
        Part.sendData(OutputStream)
      • getSource

        protected PartSource getSource()
        Returns the source of the file part.
        Returns:
        The source.
      • lengthOfData

        protected long lengthOfData()
                             throws java.io.IOException
        Return the length of the data.
        Specified by:
        lengthOfData in class Part
        Returns:
        The length.
        Throws:
        java.io.IOException - if an IO problem occurs
        See Also:
        Part.lengthOfData()