Class Request
Definition
- Assembly:
- Tizen.Content.Download.dll
The Request class provides the functions to create and manage a single download request.
public class Request : IDisposable
- Inheritance
-
objectRequest
- Implements
-
System.IDisposable
Constructors
View SourceRequest(string, string, string, NetworkType, IDictionary<string, string>)
Creates a Request object.
Declaration
public Request(string url, string destinationPath, string fileName, NetworkType type, IDictionary<string, string> httpHeaders)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL to download. |
| string | destinationPath | The directory path where the downloaded file is stored. |
| string | fileName | The name of the downloaded file. |
| NetworkType | type | The network type which the download request must adhere to. |
| System.Collections.Generic.IDictionary<TKey, TValue><string, string> | httpHeaders | HTTP header fields for the download request. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
| System.NotSupportedException | Thrown when a feature is not supported. |
Request(string, string, string, NetworkType)
Creates a Request object.
Declaration
public Request(string url, string destinationPath, string fileName, NetworkType type)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL to download |
| string | destinationPath | The directory path where downloaded file is stored. |
| string | fileName | The name of the downloaded file. |
| NetworkType | type | The network type which the download request must adhere to. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
| System.NotSupportedException | Thrown when a feature is not supported. |
Request(string)
Creates a Request object.
Declaration
public Request(string url)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL to download. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
Properties
View SourceAllowedNetworkType
The allowed network type for downloading the file. The file will be downloaded only under the allowed network. If you try to get this property value before setting or if any other error occurs, the default value NetworkType All is returned.
Declaration
public NetworkType AllowedNetworkType { get; set; }
Property Value
| Type | Description |
|---|---|
| NetworkType |
Remarks
Should be set before calling Start().
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
| System.NotSupportedException | Thrown when feature is not supported. |
AutoDownload
Enables or disables auto download. If this option is enabled, the previous downloading item is restarted automatically as soon as the download daemon is restarted. The download progress continues after the client process is terminated. If you try to get this property value before setting, the default value false is returned.
Declaration
public bool AutoDownload { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
The default value is false.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
ContentName
The content name of the downloaded file. This can be defined with reference of the HTTP response header data. The content name can be received when the HTTP response header is received. If you try to get this property value before calling Start(), an empty string is returned.
Declaration
public string ContentName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
ContentSize
The total size of the downloaded content. This information is received from the server. If the server does not send the total size of the content, the content size is set to zero. If you try to get this property value before calling Start(), 0 is returned.
Declaration
public ulong ContentSize { get; }
Property Value
| Type | Description |
|---|---|
| ulong |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
DestinationPath
The file will be downloaded to the set the destination file path. The downloaded file is saved to an auto-generated file name in the destination. If the destination is not specified, the file will be downloaded to the default storage. If you try to get this property value before setting or if any other error occurs, an empty string is returned.
Declaration
public string DestinationPath { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Should be set before calling Start().
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
DownloadedPath
The absolute path where the file will be downloaded. If you try to get this property value before calling Start(), an empty string is returned.
Declaration
public string DownloadedPath { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Returns an empty string if the download is not completed or if a state has not yet changed to completed or if any other error occurs.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
ETagValue
The ETag value from the HTTP response header when making a HTTP request for resume. If you try to get this property value before calling Start() or if any other error occurs, an empty string is returned.
Declaration
public string ETagValue { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
The ETag value is either available or not dependent on the web server. If not available, then, on getting the property, a null value is returned. After the download is started, it can get the ETag value.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
FileName
The file will be saved in the specified destination or the default storage with the set file name. If the file name is not specified, the downloaded file will be saved with an auto-generated file name in the destination. If you try to get this property value before setting or if any other error occurs, an empty string is returned.
Declaration
public string FileName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Should be set before calling Start().
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
HttpHeaders
The HTTP header field and value pairs to the download request. The HTTP header <field,value> pair is the <key,value> pair in the dictionary HttpHeaders. The given HTTP header field will be included with the HTTP request of the download request. If you try to get this property value before setting, an empty dictionary is returned.
Declaration
public IDictionary<string, string> HttpHeaders { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue><string, string> |
Remarks
HTTP header fields should be set before calling Start(). HTTP header fields can be removed before calling Start().
HttpStatus
The HTTP status code when a download exception occurs. If you try to get this property value before calling Start(), 0 is returned.
Declaration
public int HttpStatus { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
The state of the download request must be DownlodState.Failed.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
MimeType
The MIME type of the downloaded content. If you try to get this property value before calling Start(), an empty string is returned.
Declaration
public string MimeType { get; }
Property Value
| Type | Description |
|---|---|
| string |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
NotificationProperties
Contains properties required for creating download notifications.
Declaration
public Notification NotificationProperties { get; }
Property Value
| Type | Description |
|---|---|
| Notification |
Remarks
When the notification message is clicked, the action taken by the system is decided by the application control properties of the NotificationProperties instance. If the app control is not set, the following default operation is executed when the notification message is clicked:
- The download completed state - the viewer application is executed according to the extension name of the downloaded content.
- The download failed state and ongoing state - the client application is executed. This property should be set before calling Start().
State
The current state of the download.
Declaration
public DownloadState State { get; }
Property Value
| Type | Description |
|---|---|
| DownloadState |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
TemporaryPath
The full path of the temporary file stores the downloaded content.
Declaration
public string TemporaryPath { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
The download state must be one of the states after downloading.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
Url
The URL to download.
Declaration
public string Url { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Should be set before calling Start(). If you try to get this property value before setting or if any other error occurs, an empty string is returned.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
UsesCache
Enabled state of the cache feature.
Declaration
public bool UsesCache { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to setting an invalid value. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
| System.NotSupportedException | Thrown when not supported. |
Methods
View SourceCancel()
Cancels the download request.
Declaration
public void Cancel()
Remarks
The canceled download can be restarted with Start().
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
Dispose()
Releases all the resources used by the Request class.
Declaration
public void Dispose()
Remarks
After calling this method, the download request related data exists in the download database for a certain period of time. Within that time, it is possible to use other APIs with this data.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
Dispose(bool)
Deletes the corresponding download request.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
~Request()
Destructor of the Request class.
Declaration
protected ~Request()
Pause()
Pauses the download request.
Declaration
public void Pause()
Remarks
The paused download request can be restarted with Start() or canceled with Cancel().
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
SetTemporaryFilePath(string)
Sets the directory path of a temporary file used in a previous download request. This is only useful when resuming download to make the HTTP request header at the client side. Otherwise, the path is ignored.
Declaration
public void SetTemporaryFilePath(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path |
Remarks
If the ETag value is not present in the download database, it is not useful to set the temporary file path. When resuming the download request, the data is attached at the end of this temporary file.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
Start()
Starts or resumes the download. Starts to download the current URL, or resumes the download if paused.
Declaration
public void Start()
Remarks
The URL is the mandatory information to start the download.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
Events
View SourceProgressChanged
An event that occurs when the download progress changes.
Declaration
public event EventHandler<ProgressChangedEventArgs> ProgressChanged
Event Type
| Type | Description |
|---|---|
| System.EventHandler<TEventArgs><ProgressChangedEventArgs> |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |
StateChanged
An event that occurs when the download state changes.
Declaration
public event EventHandler<StateChangedEventArgs> StateChanged
Event Type
| Type | Description |
|---|---|
| System.EventHandler<TEventArgs><StateChangedEventArgs> |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown when it is failed due to an invalid parameter. |
| System.InvalidOperationException | Thrown when it is failed due to an invalid operation. |
| System.UnauthorizedAccessException | Thrown when a permission is denied. |