Class Upload
- All Implemented Interfaces:
AutoCloseable
Upload files with HTTP POST, form fields, headers, progress tracking, and TLS control.
Chilkat.Upload sends files to a web server using HTTP POST,
typically as a multipart/form-data upload. It supports one or more file
references, custom form parameters, custom HTTP headers, blocking and
asynchronous uploads, progress monitoring, upload throttling, Basic HTTP
authentication, proxy settings, HTTPS/TLS configuration, timeout control, and
inspection of the HTTP response returned by the server.
File upload requests
Add one or more local file references and send them to a server endpoint using HTTP POST.
Form parameters
Add ordinary form fields alongside file parts when the server expects metadata, tokens, IDs, or other POST parameters.
Custom headers
Include application-specific HTTP headers for authorization schemes, API requirements, content negotiation, or server-side routing.
Blocking or async upload
Use a simple blocking upload, begin an upload in the background, or use async task-based workflows where supported.
Progress and throttling
Monitor bytes sent, percent uploaded, current filename, upload state, and optionally throttle upload bandwidth.
Authentication, proxy, and TLS
Configure Basic authentication, HTTP/SOCKS proxy settings, HTTPS/TLS behavior, cipher restrictions, protocol versions, and certificate pinning.
Common pattern:
Set the server Hostname, Port, Ssl,
and upload Path, add file references with
AddFileReference, add any form parameters or headers, then call
BlockingUpload or start an asynchronous upload. After completion,
inspect ResponseStatus, ResponseHeader,
ResponseBody, and LastErrorText to determine what
the server returned.
For an extended overview, see Upload Class Overview.
</section>
Event-capable: long-running methods report progress through a ProgressListener installed
with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier),
onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMay be called during an asynchronous upload to abort.voidaddCustomHeader(String name, String value)Adds a custom HTTP header to the HTTP upload.voidaddFileReference(String name, String filename)Adds a file to the list of files to be uploaded in the next call to BlockingUpload, BeginUpload, or UploadToMemory.voidAdds a custom HTTP request parameter to the upload.voidStarts an asynchronous upload.voidUploads files to a web server using HTTP.voidClears the internal list of files created by calls to AddFileReference.voidClears the internal list of params created by calls to AddParam.booleanWhen set totrue, causes the currently running method to abort.intIf non-zero, limits (throttles) the upload bandwidth to approximately this maximum number of bytes per second.intThe chunk size (in bytes) used by the underlying TCP/IP sockets for uploading files.The IP address to use for computers with multiple network interfaces or IP addresses.The current filename being uploaded while an asynchronous upload is in progress.booleanWhentrue, the request header will included anExpect: 100-continueheader field.intThe interval in milliseconds between eachevent callback, which enables an application to abort certain method calls before they complete.AbortCheckThe hostname of the HTTP server that is the target of the upload.intA timeout in milliseconds.getLogin()The HTTP login for sites requiring authentication.longAfter an upload has completed, this property contains the number of bytes sent.The HTTP password for sites requiring authentication.getPath()The path part of the upload URL.intThis property is only valid in programming environment and languages that allow for event callbacks.longContains the current percentage completion (0 to 100) while an asynchronous upload is in progress.intgetPort()The port number of the upload target (i.e.booleanIftrue, then use IPv6 over IPv4 when both are supported for a particular domain.Returns the installed listener, ornull.The domain name of a proxy host if an HTTP proxy is used.If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy login.If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy password.intThe port number of a proxy server if an HTTP proxy is used.Returns the response body as a string.An HTTP upload is nothing more than an HTTP POST that contains the content of the files being uploaded.intThe HTTP response status code of the HTTP response.booleangetSsl()Set this totrueif the upload is to HTTPS.Provides a means for setting a list of ciphers that are allowed for SSL/TLS connections.Selects the secure protocol to be used for secure (SSL/TLS) connections.Specifies a set of pins for Public Key Pinning for TLS connections.longThe total size of the upload (in bytes).booleanSet totruewhen an asynchronous upload is started.booleanSet totrue(success) orfalse(failed) after an asynchronous upload completes or aborts due to failure.voidonAbortCheck(BooleanSupplier callback)Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it.voidonPercentDone(IntPredicate callback)Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it.voidonProgressInfo(BiConsumer<String,String> callback)Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds.voidsetAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().voidsetBandwidthThrottleUp(int value)Sets theBandwidthThrottleUpproperty; seegetBandwidthThrottleUp().voidsetChunkSize(int value)Sets theChunkSizeproperty; seegetChunkSize().voidsetClientIpAddress(String value)Sets theClientIpAddressproperty; seegetClientIpAddress().voidsetExpect100Continue(boolean value)Sets theExpect100Continueproperty; seegetExpect100Continue().voidsetHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().voidsetHostname(String value)Sets theHostnameproperty; seegetHostname().voidsetIdleTimeoutMs(int value)Sets theIdleTimeoutMsproperty; seegetIdleTimeoutMs().voidSets theLoginproperty; seegetLogin().voidsetPassword(String value)Sets thePasswordproperty; seegetPassword().voidSets thePathproperty; seegetPath().voidsetPercentDoneScale(int value)Sets thePercentDoneScaleproperty; seegetPercentDoneScale().voidsetPort(int value)Sets thePortproperty; seegetPort().voidsetPreferIpv6(boolean value)Sets thePreferIpv6property; seegetPreferIpv6().voidsetProgressListener(ProgressListener listener)Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.voidsetProxyDomain(String value)Sets theProxyDomainproperty; seegetProxyDomain().voidsetProxyLogin(String value)Sets theProxyLoginproperty; seegetProxyLogin().voidsetProxyPassword(String value)Sets theProxyPasswordproperty; seegetProxyPassword().voidsetProxyPort(int value)Sets theProxyPortproperty; seegetProxyPort().voidsetSsl(boolean value)Sets theSslproperty; seegetSsl().voidsetSslAllowedCiphers(String value)Sets theSslAllowedCiphersproperty; seegetSslAllowedCiphers().voidsetSslProtocol(String value)Sets theSslProtocolproperty; seegetSslProtocol().voidsetTlsPinSet(String value)Sets theTlsPinSetproperty; seegetTlsPinSet().voidsleepMs(int millisec)A convenience method for putting the calling process to sleep for N milliseconds.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Upload
public Upload()Creates a newUploadobject.
-
-
Method Details
-
getAbortCurrent
public boolean getAbortCurrent()When set totrue, causes the currently running method to abort. Methods that always finish quickly (i.e.have no length file operations or network communications) are not affected. If no method is running, then this property is automatically reset tofalsewhen the next method is called. When the abort occurs, this property is reset tofalse. Both synchronous and asynchronous method calls can be aborted. (A synchronous method call could be aborted by setting this property from a separate thread.)- Returns:
- the value of the
AbortCurrentproperty
-
setAbortCurrent
public void setAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().- Parameters:
value- the new value
-
getBandwidthThrottleUp
public int getBandwidthThrottleUp()If non-zero, limits (throttles) the upload bandwidth to approximately this maximum number of bytes per second. The default value of this property is 0.- Returns:
- the value of the
BandwidthThrottleUpproperty
-
setBandwidthThrottleUp
public void setBandwidthThrottleUp(int value)Sets theBandwidthThrottleUpproperty; seegetBandwidthThrottleUp().- Parameters:
value- the new value
-
getChunkSize
public int getChunkSize()The chunk size (in bytes) used by the underlying TCP/IP sockets for uploading files. The default value is 65535.- Returns:
- the value of the
ChunkSizeproperty
-
setChunkSize
public void setChunkSize(int value)Sets theChunkSizeproperty; seegetChunkSize().- Parameters:
value- the new value
-
getClientIpAddress
The IP address to use for computers with multiple network interfaces or IP addresses. For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.The IP address is a string such as in dotted notation using numbers, not domain names, such as
165.164.55.124.- Returns:
- the value of the
ClientIpAddressproperty
-
setClientIpAddress
Sets theClientIpAddressproperty; seegetClientIpAddress().- Parameters:
value- the new value (notnull)
-
getCurrentFilename
The current filename being uploaded while an asynchronous upload is in progress.- Returns:
- the value of the
CurrentFilenameproperty (read-only)
-
getExpect100Continue
public boolean getExpect100Continue()Whentrue, the request header will included anExpect: 100-continueheader field. This indicates that the server should respond with an intermediate response of100 Continueor417 Expectation Failedresponse based on the information available in the request header. This helps avoid situations such as limits on upload sizes. It allows the server to reject the upload, and then the client can abort prior to uploading the data.The default value of this property is
true.- Returns:
- the value of the
Expect100Continueproperty
-
setExpect100Continue
public void setExpect100Continue(boolean value)Sets theExpect100Continueproperty; seegetExpect100Continue().- Parameters:
value- the new value
-
getHeartbeatMs
public int getHeartbeatMs()The interval in milliseconds between eachevent callback, which enables an application to abort certain method calls before they complete. By default, HeartbeatMs is set toAbortCheck0, meaning no AbortCheck event callbacks will trigger.- Returns:
- the value of the
HeartbeatMsproperty
-
setHeartbeatMs
public void setHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().- Parameters:
value- the new value
-
getHostname
The hostname of the HTTP server that is the target of the upload. Do not includehttp://in the hostname. It can be a hostname, such aswww.chilkatsoft.com, or an IP address, such as168.144.70.227.- Returns:
- the value of the
Hostnameproperty
-
setHostname
Sets theHostnameproperty; seegetHostname().- Parameters:
value- the new value (notnull)
-
getIdleTimeoutMs
public int getIdleTimeoutMs()A timeout in milliseconds. The default value is 30000. If the upload hangs (i.e. progress halts) for more than this time, the component will abort the upload. (It will timeout.)- Returns:
- the value of the
IdleTimeoutMsproperty
-
setIdleTimeoutMs
public void setIdleTimeoutMs(int value)Sets theIdleTimeoutMsproperty; seegetIdleTimeoutMs().- Parameters:
value- the new value
-
getLogin
The HTTP login for sites requiring authentication. Chilkat Upload supports Basic HTTP authentication.- Returns:
- the value of the
Loginproperty
-
setLogin
Sets theLoginproperty; seegetLogin().- Parameters:
value- the new value (notnull)
-
getNumBytesSent
public long getNumBytesSent()After an upload has completed, this property contains the number of bytes sent. During asynchronous uploads, this property contains the current number of bytes sent while the upload is in progress.- Returns:
- the value of the
NumBytesSentproperty (read-only)
-
getPassword
The HTTP password for sites requiring authentication. Chilkat Upload supports Basic HTTP authentication.- Returns:
- the value of the
Passwordproperty
-
setPassword
Sets thePasswordproperty; seegetPassword().- Parameters:
value- the new value (notnull)
-
getPath
The path part of the upload URL. Some examples:desc>
If the upload target (i.e. consumer) URL is: http://www.freeaspupload.net/freeaspupload/testUpload.asp, then
Hostname =
If the upload target URL is https://www.chilkatsoft.com/cgi-bin/ConsumeUpload.exe, thenwww.freeaspupload.netPath =/freeaspupload/testUpload.aspHostname =
www.chilkatsoft.comPath =/cgi-bin/ConsumeUpload.exe- Returns:
- the value of the
Pathproperty
-
setPath
Sets thePathproperty; seegetPath().- Parameters:
value- the new value (notnull)
-
getPercentDoneScale
public int getPercentDoneScale()This property is only valid in programming environment and languages that allow for event callbacks.Sets the value to be defined as 100% complete for the purpose of PercentDone event callbacks. The defaut value of 100 means that at most 100 event PercentDone callbacks will occur in a method that (1) is event enabled and (2) is such that it is possible to measure progress as a percentage completed. This property may be set to larger numbers to get more fine-grained PercentDone callbacks. For example, setting this property equal to 1000 will provide callbacks with .1 percent granularity. For example, a value of 453 would indicate 45.3% competed. This property is clamped to a minimum value of 10, and a maximum value of 100000.
- Returns:
- the value of the
PercentDoneScaleproperty
-
setPercentDoneScale
public void setPercentDoneScale(int value)Sets thePercentDoneScaleproperty; seegetPercentDoneScale().- Parameters:
value- the new value
-
getPercentUploaded
public long getPercentUploaded()Contains the current percentage completion (0 to 100) while an asynchronous upload is in progress.- Returns:
- the value of the
PercentUploadedproperty (read-only)
-
getPort
public int getPort()The port number of the upload target (i.e. consumer) URL. The default value is 80. If SSL is used, this should be set to 443 (typically).- Returns:
- the value of the
Portproperty
-
setPort
public void setPort(int value)Sets thePortproperty; seegetPort().- Parameters:
value- the new value
-
getPreferIpv6
public boolean getPreferIpv6()Iftrue, then use IPv6 over IPv4 when both are supported for a particular domain. The default value of this property isfalse, which will choose IPv4 over IPv6.- Returns:
- the value of the
PreferIpv6property
-
setPreferIpv6
public void setPreferIpv6(boolean value)Sets thePreferIpv6property; seegetPreferIpv6().- Parameters:
value- the new value
-
getProxyDomain
The domain name of a proxy host if an HTTP proxy is used. Do not include thehttp://. The domain name may be a hostname, such aswww.chilkatsoft.com, or an IP address, such as168.144.70.227.- Returns:
- the value of the
ProxyDomainproperty
-
setProxyDomain
Sets theProxyDomainproperty; seegetProxyDomain().- Parameters:
value- the new value (notnull)
-
getProxyLogin
If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy login.- Returns:
- the value of the
ProxyLoginproperty
-
setProxyLogin
Sets theProxyLoginproperty; seegetProxyLogin().- Parameters:
value- the new value (notnull)
-
getProxyPassword
If an HTTP proxy is used and it requires authentication, this property specifies the HTTP proxy password.- Returns:
- the value of the
ProxyPasswordproperty
-
setProxyPassword
Sets theProxyPasswordproperty; seegetProxyPassword().- Parameters:
value- the new value (notnull)
-
getProxyPort
public int getProxyPort()The port number of a proxy server if an HTTP proxy is used.- Returns:
- the value of the
ProxyPortproperty
-
setProxyPort
public void setProxyPort(int value)Sets theProxyPortproperty; seegetProxyPort().- Parameters:
value- the new value
-
getResponseBodyStr
Returns the response body as a string.- Returns:
- the value of the
ResponseBodyStrproperty (read-only)
-
getResponseHeader
An HTTP upload is nothing more than an HTTP POST that contains the content of the files being uploaded. Just as with any HTTP POST or GET, the server should send an HTTP response that consists of header and body.desc>This property contains the header part of the HTTP response.
- Returns:
- the value of the
ResponseHeaderproperty (read-only)
-
getResponseStatus
public int getResponseStatus()The HTTP response status code of the HTTP response. A list of HTTP status codes can be found here: HTTP Response Status Codes.- Returns:
- the value of the
ResponseStatusproperty (read-only)
-
getSsl
public boolean getSsl()Set this totrueif the upload is to HTTPS. For example, if the target of the upload is:https://www.myuploadtarget.com/consumeUpload.asp
desc>then set:
Ssl =
true
Hostname =www.myuploadtarget.com
Path =/consumeupload.asp
Port = 443
- Returns:
- the value of the
Sslproperty
-
setSsl
public void setSsl(boolean value)Sets theSslproperty; seegetSsl().- Parameters:
value- the new value
-
getSslAllowedCiphers
Provides a means for setting a list of ciphers that are allowed for SSL/TLS connections. The default (empty string) indicates that all implemented ciphers are possible. The TLS ciphers supported in Chilkat v9.5.0.55 and later are:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 TLS_DHE_RSA_WITH_AES_256_CBC_SHA TLS_RSA_WITH_AES_256_CBC_SHA256 TLS_RSA_WITH_AES_256_GCM_SHA384 TLS_RSA_WITH_AES_256_CBC_SHA TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_RSA_WITH_AES_128_CBC_SHA256 TLS_RSA_WITH_AES_128_GCM_SHA256 TLS_RSA_WITH_AES_128_CBC_SHA TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA TLS_RSA_WITH_3DES_EDE_CBC_SHA TLS_ECDHE_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_RC4_128_MD5 TLS_DHE_RSA_WITH_DES_CBC_SHA TLS_RSA_WITH_DES_CBC_SHA
To restrict SSL/TLS connections to one or more specific ciphers, set this property to a comma-separated list of ciphers such as
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. The order should be in terms of preference, with the preferred algorithms listed first. (Note that the client cannot specifically choose the algorithm is picked because it is the server that chooses. The client simply provides the server with a list from which to choose.)The property can also disallow connections with servers having certificates with RSA keys less than a certain size. By default, server certificates having RSA keys of 512 bits or greater are allowed. Add the keyword
rsa1024to disallow connections with servers having keys smaller than 1024 bits. Add the keywordrsa2048to disallow connections with servers having keys smaller than 2048 bits.Note: Prior to Chilkat v9.5.0.55, it was not possible to explicitly list allowed cipher suites. The deprecated means for indicating allowed ciphers was both incomplete and unprecise. For example, the following keywords could be listed to allow matching ciphers:
aes256-cbc,aes128-cbc,3des-cbc, andrc4. These keywords will still be recognized, but programs should be updated to explicitly list the allowed ciphers.secure-renegotiation: Starting in Chilkat v9.5.0.55, the keyword
secure-renegotiationmay be added to require that all renegotions be done securely (as per RFC 5746).best-practices: Starting in Chilkat v9.5.0.55, this property may be set to the single keyword
best-practices. This will allow ciphers based on the current best practices. As new versions of Chilkat are released, the best practices may change. Changes will be noted here. The current best practices are:- If the server uses an RSA key, it must be 1024 bits or greater.
- All renegotations must be secure renegotiations.
- All ciphers using RC4, DES, or 3DES are disallowed.
Example: The following string would restrict to 2 specific cipher suites, require RSA keys to be 1024 bits or greater, and require secure renegotiations:
TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, rsa1024, secure-renegotiation- Returns:
- the value of the
SslAllowedCiphersproperty
-
setSslAllowedCiphers
Sets theSslAllowedCiphersproperty; seegetSslAllowedCiphers().- Parameters:
value- the new value (notnull)
-
getSslProtocol
Selects the secure protocol to be used for secure (SSL/TLS) connections. Possible values are:default
The default value is
TLS 1.3
TLS 1.2
TLS 1.1
TLS 1.0
SSL 3.0
TLS 1.3 or higher
TLS 1.2 or higher
TLS 1.1 or higher
TLS 1.0 or higher
defaultwhich will choose the, which allows for the protocol to be selected dynamically at runtime based on the requirements of the server. Choosing an exact protocol will cause the connection to fail unless that exact protocol is negotiated. It is better to chooseX or higherthan an exact protocol. Thedefaultis effectivelySSL 3.0 or higher.- Returns:
- the value of the
SslProtocolproperty
-
setSslProtocol
Sets theSslProtocolproperty; seegetSslProtocol().- Parameters:
value- the new value (notnull)
-
getTlsPinSet
Specifies a set of pins for Public Key Pinning for TLS connections. This property lists the expected SPKI fingerprints for the server certificates. If the server's certificate (sent during the TLS handshake) does not match any of the SPKI fingerprints, then the TLS handshake is aborted and the connection fails. The format of this string property is as follows:hash_algorithm, encoding, SPKI_fingerprint_1, SPKI_fingerprint_2, ...
For example, the following string specifies a single sha256 base64-encoded SPKI fingerprint:
"sha256, base64, lKg1SIqyhPSK19tlPbjl8s02yChsVTDklQpkMCHvsTE="
This example specifies two SPKI fingerprints:
"sha256, base64, 4t37LpnGmrMEAG8HEz9yIrnvJV2euVRwCLb9EH5WZyI=, 68b0G5iqMvWVWvUCjMuhLEyekM5729PadtnU5tdXZKs="
Any of the following hash algorithms are allowed:.sha1, sha256, sha384, sha512, md2, md5, haval, ripemd128, ripemd160,ripemd256, or ripemd320.
The following encodings are allowed: base64, hex, and any of the encodings indicated in the link below.
- Returns:
- the value of the
TlsPinSetproperty
-
setTlsPinSet
Sets theTlsPinSetproperty; seegetTlsPinSet().- Parameters:
value- the new value (notnull)
-
getTotalUploadSize
public long getTotalUploadSize()The total size of the upload (in bytes). This property will become set at the beginning of an asynchronous upload. A program may monitor asynchronous uploads by tracking both NumBytesSent and PercentUploaded.desc> This property is also set during synchronous uploads.
- Returns:
- the value of the
TotalUploadSizeproperty (read-only)
-
getUploadInProgress
public boolean getUploadInProgress()Set totruewhen an asynchronous upload is started. When the asynchronous upload is complete, this property becomes equal tofalse. A program will typically begin an asynchronous upload by calling BeginUpload, and then periodically checking the value of this property to determine when the upload is complete.- Returns:
- the value of the
UploadInProgressproperty (read-only)
-
getUploadSuccess
public boolean getUploadSuccess()Set totrue(success) orfalse(failed) after an asynchronous upload completes or aborts due to failure. When a program does an asynchronous upload, it will wait until UploadInProgress becomesfalse. It will then check the value of this property to determine if the upload was successful or not.- Returns:
- the value of the
UploadSuccessproperty (read-only)
-
abortUpload
public void abortUpload()May be called during an asynchronous upload to abort. -
addCustomHeader
Adds a custom HTTP header to the HTTP upload.- Parameters:
name- thenameargument (notnull)value- thevalueargument (notnull)
-
addFileReference
Adds a file to the list of files to be uploaded in the next call to BlockingUpload, BeginUpload, or UploadToMemory. To upload more than one file, call this method once for each file to be uploaded.- Parameters:
name- thenameargument (notnull)filename- thefilenameargument (notnull)
-
addParam
Adds a custom HTTP request parameter to the upload.- Parameters:
name- thenameargument (notnull)value- thevalueargument (notnull)
-
beginUpload
public void beginUpload()Starts an asynchronous upload. Only one asynchronous upload may be in progress at a time. To achieve multiple asynchronous uploads, use multiple instances of the Chilkat Upload object. Each object instance is capable of managing a single asynchronous upload.desc> When this method is called, a background thread is started and the asynchronous upload runs in the background. The upload may be aborted at any time by calling AbortUpload. The upload is completed (or failed) when UploadInProgress becomes
false. At that point, the UploadSuccess property may be checked to determine success (true) or failure (false).- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
blockingUpload
public void blockingUpload()Uploads files to a web server using HTTP. The files to be uploaded are indicated by calling AddFileReference once for each file (prior to calling this method).- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
clearFileReferences
public void clearFileReferences()Clears the internal list of files created by calls to AddFileReference. -
clearParams
public void clearParams()Clears the internal list of params created by calls to AddParam. -
sleepMs
public void sleepMs(int millisec)A convenience method for putting the calling process to sleep for N milliseconds. It is provided here because some programming languages do not provide this capability, and sleeping for short increments of time is helpful when doing asynchronous uploads.- Parameters:
millisec- themillisecargument
-
setProgressListener
Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.- Parameters:
listener- the listener, ornull- Throws:
IllegalStateException- if called from inside one of this object's own callbacks
-
getProgressListener
Returns the installed listener, ornull.- Returns:
- the listener installed with
setProgressListener(ProgressListener)or one of theon...methods
-
onAbortCheck
Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onPercentDone
Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onProgressInfo
Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-