Class Request

Definition

Namespace:
Tizen.Content.Download
Assembly:
Tizen.Content.Download.dll
API Level:
3

The Request class provides the functions to create and manage a single download request.

C#
Copy
public class Request : IDisposable
Inheritance
System.Object
Request
Implements
System.IDisposable

Constructors

View Source

Request(String)

Creates a Request object.

Declaration
C#
Copy
public Request(string url)
Parameters
Type Name Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

Request(String, String, String, NetworkType)

Creates a Request object.

Declaration
C#
Copy
public Request(string url, string destinationPath, string fileName, NetworkType type)
Parameters
Type Name Description
System.String url

The URL to download

System.String destinationPath

The directory path where downloaded file is stored.

System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

System.NotSupportedException

Thrown when a feature is not supported.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
Feature: http://tizen.org/feature/network.wifihttp://tizen.org/feature/network.wifi.directhttp://tizen.org/feature/network.telephony
View Source

Request(String, String, String, NetworkType, IDictionary<String, String>)

Creates a Request object.

Declaration
C#
Copy
public Request(string url, string destinationPath, string fileName, NetworkType type, IDictionary<string, string> httpHeaders)
Parameters
Type Name Description
System.String url

The URL to download.

System.String destinationPath

The directory path where the downloaded file is stored.

System.String fileName

The name of the downloaded file.

NetworkType type

The network type which the download request must adhere to.

IDictionary<System.String, System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

System.NotSupportedException

Thrown when a feature is not supported.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
Feature: http://tizen.org/feature/network.wifihttp://tizen.org/feature/network.wifi.directhttp://tizen.org/feature/network.telephony

Properties

View Source

AllowedNetworkType

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
C#
Copy
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.

UnauthorizedAccessException

Thrown when a permission is denied.

System.NotSupportedException

Thrown when feature is not supported.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
Feature: http://tizen.org/feature/network.wifihttp://tizen.org/feature/network.wifi.directhttp://tizen.org/feature/network.telephony
View Source

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
C#
Copy
public bool AutoDownload { get; set; }
Property Value
Type Description
Boolean
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public string ContentName { get; }
Property Value
Type Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public ulong ContentSize { get; }
Property Value
Type Description
System.UInt64
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public string DestinationPath { get; set; }
Property Value
Type Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public string DownloadedPath { get; }
Property Value
Type Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public string ETagValue { get; }
Property Value
Type Description
System.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

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public string FileName { get; set; }
Property Value
Type Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public IDictionary<string, string> HttpHeaders { get; }
Property Value
Type Description
IDictionary<System.String, System.String>
Remarks

HTTP header fields should be set before calling Start(). HTTP header fields can be removed before calling Start().

API Level: 3
View Source

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
C#
Copy
public int HttpStatus { get; }
Property Value
Type Description
Int32
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public string MimeType { get; }
Property Value
Type Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

NotificationProperties

Contains properties required for creating download notifications.

Declaration
C#
Copy
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: 1) The download completed state - the viewer application is executed according to the extension name of the downloaded content. 2) The download failed state and ongoing state - the client application is executed. This property should be set before calling Start().

API Level: 3
View Source

State

The current state of the download.

Declaration
C#
Copy
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

TemporaryPath

The full path of the temporary file stores the downloaded content.

Declaration
C#
Copy
public string TemporaryPath { get; }
Property Value
Type Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

Url

The URL to download.

Declaration
C#
Copy
public string Url { get; set; }
Property Value
Type Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download

Methods

View Source

Cancel()

Cancels the download request.

Declaration
C#
Copy
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

Dispose()

Releases all the resources used by the Request class.

Declaration
C#
Copy
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

Dispose(Boolean)

Deletes the corresponding download request.

Declaration
C#
Copy
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
Boolean 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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

Finalize()

Destructor of the Request class.

Declaration
C#
Copy
protected void Finalize()
View Source

Pause()

Pauses the download request.

Declaration
C#
Copy
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

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
C#
Copy
public void SetTemporaryFilePath(string path)
Parameters
Type Name Description
System.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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

Start()

Starts or resumes the download. Starts to download the current URL, or resumes the download if paused.

Declaration
C#
Copy
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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download

Events

View Source

ProgressChanged

An event that occurs when the download progress changes.

Declaration
C#
Copy
public event EventHandler<ProgressChangedEventArgs> ProgressChanged
Event Type
Type Description
System.EventHandler<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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download
View Source

StateChanged

An event that occurs when the download state changes.

Declaration
C#
Copy
public event EventHandler<StateChangedEventArgs> StateChanged
Event Type
Type Description
System.EventHandler<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.

UnauthorizedAccessException

Thrown when a permission is denied.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/download

Implements

System.IDisposable