httpsupload:multiple

Full name:

com.addicticks.oss.maven:httpsupload-maven-plugin:1.1.7:multiple

Description:

Uploads multiple file to a remote server using HTTP or HTTPS. This goal should only be used with servers that accepts multiple file to be uploaded in a single operation.

Files are sent using POST method and using multipart/form-data encoding (RFC2388).

Attributes:

Required Parameters

Name Type Since Description
targetURL URL - The URL to upload the file(s) to. Must be either HTTP or HTTPS protocol.

The plugin derives which protocol to use from this value.

Examples:

  https://solar.mycompany.com/upload
  http://pluto.vanilla.org/acceptfiles

uploadFiles List - Files to upload.

Example:

    <uploadFiles>
        <uploadFile>
            <file>${project.build.directory}/myfile.jar</file>
        </uploadFile>
        <uploadFile>
            <formFieldName>file2</formFieldName>
            <file>c://mydir/whatsup.dat</file>
            <hintFilename>whatsup.xls</hintFilename>
        </uploadFile>
    </uploadFiles>

There must be at least one uploadFile element.

The elements of an uploadFile are as follows:

  • file. File to upload.
    Type: java.io.File, Required: Yes

  • hintFilename. Hint given to the server as to what the server should name the file. If this value is not set explicitly it will be derived from the filename of the file element.
    Type: String, Required: No

  • mimeType. This is the http Content-Type used when the file is uploaded. If not given explicitly here it will be derived from the file name extension using Java's URLConnection.guessContentTypeFromName() method and if this fails then application/octet-stream will be used.
    Type: String, Required: No

  • formFieldName. The form field name to POST the file to. This value depends entirely on the server you're uploading to. Typically such a field is named "file". There's no requirement that the value is unique among the files to be uploaded. If you don't know what this value should be then leave it out. If no value is supplied then the plugin will automatically supply the names file, file2, file3,... and so on, to those <uploadFile> elements where no value was supplied.
    Type: String, Required: No



Optional Parameters

Name Type Since Description
additionalHeaders Map - Sets additional overall HTTP headers to add to the upload POST request. There's rarely a need to use this parameter.

The following header fields are automatically set:

   "Connection"
   "Cache-Control"
   "Content-Type"
   "Content-Length"
   "Authorization"
and you must never set these here. (if you do they will be ignored).

However you might want to use this parameter to explicitly set e.g. User-Agent or non-standard header fields that are required for your particular endpoint. For example by overriding User-Agent you can make the upload operation look to the endpoint as if it comes from a browser.

Example:

    <additionalHeaders>
        <!-- impersonate Safari browser on iPad  -->
        <User-Agent>Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405</User-Agent>
        <!--  just an example of a really weird header field  -->
        <From>joe@mycorp.com</From>
    </additionalHeaders>

connectTimeoutMs int - Connect timeout (in milliseconds) to use when connecting to the endpoint.

If the URL is specified with a hostname as opposed to an IP address then a name lookup needs to be performed. This is not included in the connect timeout. The connect timeout is the time it takes to establish the tcp connection, nothing else. The timeout for name resolution (DNS lookup) is platform dependent.


Default value is: 10000.
extraFields Map - Extra fields to send along with the file upload. The keys of the map are the field names and the value their (String) content.

Example

   <extraFields>
       <field1>value1</field1>
       <field2>value2</field2>
       ...
   </extraFields>

Typical use cases: Extra fields are often used to provide information about the uploader such as a name or an e-mail address. Or they can convey additional information about where the server should put the files, such as a destination folder or similar.

NB: Don't set the filename field here. Posting content for filename is handled automatically.


indicateProgress boolean - Can be used to turn off upload progress logging (if parameter value is false). By default upload progress logging is enabled. Progress logging can be a bit 'chatty'.

Files larger than 100 MBytes will see a log entry for every one percent uploaded. For files less this size there will be proportionally less log entries.

This parameter will only turn off the actual progress logging not the logging at the beginning and end of the file upload operation.


Default value is: true.
readTimeoutMs int - Read timeout (in milliseconds) to use when reading from the endpoint. This is the time from the upload has completed until the server responds.

You may have to increase this parameter if the endpoint takes a long time to process the uploaded data.


Default value is: 10000.
useAuthentication boolean - (no description)
Default value is: false.
validateCertificate boolean - Specifies if the certificate at the endpoint should be validated or not. Only relevant for HTTPS protocol, otherwise ignored.

If the value is false then the server's certificate is not validated in any way. This may be useful when working with endpoints that use a self-signed certificate.


Default value is: true.

Parameter Details

additionalHeaders:

Sets additional overall HTTP headers to add to the upload POST request. There's rarely a need to use this parameter.

The following header fields are automatically set:

   "Connection"
   "Cache-Control"
   "Content-Type"
   "Content-Length"
   "Authorization"
and you must never set these here. (if you do they will be ignored).

However you might want to use this parameter to explicitly set e.g. User-Agent or non-standard header fields that are required for your particular endpoint. For example by overriding User-Agent you can make the upload operation look to the endpoint as if it comes from a browser.

Example:

    <additionalHeaders>
        <!-- impersonate Safari browser on iPad  -->
        <User-Agent>Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405</User-Agent>
        <!--  just an example of a really weird header field  -->
        <From>joe@mycorp.com</From>
    </additionalHeaders>
  • Type: java.util.Map
  • Required: No

connectTimeoutMs:

Connect timeout (in milliseconds) to use when connecting to the endpoint.

If the URL is specified with a hostname as opposed to an IP address then a name lookup needs to be performed. This is not included in the connect timeout. The connect timeout is the time it takes to establish the tcp connection, nothing else. The timeout for name resolution (DNS lookup) is platform dependent.

  • Type: int
  • Required: No
  • Default: 10000

extraFields:

Extra fields to send along with the file upload. The keys of the map are the field names and the value their (String) content.

Example

   <extraFields>
       <field1>value1</field1>
       <field2>value2</field2>
       ...
   </extraFields>

Typical use cases: Extra fields are often used to provide information about the uploader such as a name or an e-mail address. Or they can convey additional information about where the server should put the files, such as a destination folder or similar.

NB: Don't set the filename field here. Posting content for filename is handled automatically.

  • Type: java.util.Map
  • Required: No

indicateProgress:

Can be used to turn off upload progress logging (if parameter value is false). By default upload progress logging is enabled. Progress logging can be a bit 'chatty'.

Files larger than 100 MBytes will see a log entry for every one percent uploaded. For files less this size there will be proportionally less log entries.

This parameter will only turn off the actual progress logging not the logging at the beginning and end of the file upload operation.

  • Type: boolean
  • Required: No
  • Default: true

readTimeoutMs:

Read timeout (in milliseconds) to use when reading from the endpoint. This is the time from the upload has completed until the server responds.

You may have to increase this parameter if the endpoint takes a long time to process the uploaded data.

  • Type: int
  • Required: No
  • Default: 10000

targetURL:

The URL to upload the file(s) to. Must be either HTTP or HTTPS protocol.

The plugin derives which protocol to use from this value.

Examples:

  https://solar.mycompany.com/upload
  http://pluto.vanilla.org/acceptfiles
  • Type: java.net.URL
  • Required: Yes

uploadFiles:

Files to upload.

Example:

    <uploadFiles>
        <uploadFile>
            <file>${project.build.directory}/myfile.jar</file>
        </uploadFile>
        <uploadFile>
            <formFieldName>file2</formFieldName>
            <file>c://mydir/whatsup.dat</file>
            <hintFilename>whatsup.xls</hintFilename>
        </uploadFile>
    </uploadFiles>

There must be at least one uploadFile element.

The elements of an uploadFile are as follows:

  • file. File to upload.
    Type: java.io.File, Required: Yes

  • hintFilename. Hint given to the server as to what the server should name the file. If this value is not set explicitly it will be derived from the filename of the file element.
    Type: String, Required: No

  • mimeType. This is the http Content-Type used when the file is uploaded. If not given explicitly here it will be derived from the file name extension using Java's URLConnection.guessContentTypeFromName() method and if this fails then application/octet-stream will be used.
    Type: String, Required: No

  • formFieldName. The form field name to POST the file to. This value depends entirely on the server you're uploading to. Typically such a field is named "file". There's no requirement that the value is unique among the files to be uploaded. If you don't know what this value should be then leave it out. If no value is supplied then the plugin will automatically supply the names file, file2, file3,... and so on, to those <uploadFile> elements where no value was supplied.
    Type: String, Required: No


  • Type: java.util.List
  • Required: Yes

useAuthentication:

(no description)
  • Type: boolean
  • Required: No
  • Default: false

validateCertificate:

Specifies if the certificate at the endpoint should be validated or not. Only relevant for HTTPS protocol, otherwise ignored.

If the value is false then the server's certificate is not validated in any way. This may be useful when working with endpoints that use a self-signed certificate.

  • Type: boolean
  • Required: No
  • Default: true