class sap.m.upload.Uploader

Control sample: sap.m.upload.Uploader
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/m/upload/Uploader
Application Component: CA-UI5-SC

A basic implementation for uploading and downloading one or multiple files.


Constructor

Constructor for a new Uploader.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.

new sap.m.upload.Uploader()

Properties

Name Type Default Value Description
downloadUrl string

URL where the next file is going to be download from.

Visibility: public
httpRequestMethod sap.m.upload.UploaderHttpRequestMethod Post

HTTP request method chosen for file upload.

Since: 1.90.

Visibility: public
uploadUrl string

URL where the next file is going to be uploaded to.

Visibility: public
useMultipart boolean false

This property decides the type of request. If set to "true", the request gets sent as a multipart/form-data request instead of file only request.

Since: 1.92.

Visibility: public

Events Overview

Event Description
uploadAborted

The event is fired when an XHR request reports its abortion.

uploadCompleted

The event is fired when an XHR request reports successful completion of upload process.

uploadProgressed

The event is fired every time an XHR request reports progress in uploading.

uploadStarted

The event is fired just after the POST request was sent.

uploadAborted

The event is fired when an XHR request reports its abortion.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
item sap.m.upload.UploadSetItem

The item that is going to be deleted.

uploadCompleted

The event is fired when an XHR request reports successful completion of upload process.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
item sap.m.upload.UploadSetItem

The item that was uploaded.

uploadProgressed

The event is fired every time an XHR request reports progress in uploading.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
item sap.m.upload.UploadSetItem

The item that is being uploaded.

loaded int

The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself

total int

The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.

uploadStarted

The event is fired just after the POST request was sent.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
item sap.m.upload.UploadSetItem

The item that is going to be uploaded.


Methods Overview

Method Description
attachUploadAborted

Attaches event handler fnFunction to the uploadAborted event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired when an XHR request reports its abortion.

attachUploadCompleted

Attaches event handler fnFunction to the uploadCompleted event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired when an XHR request reports successful completion of upload process.

attachUploadProgressed

Attaches event handler fnFunction to the uploadProgressed event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired every time an XHR request reports progress in uploading.

attachUploadStarted

Attaches event handler fnFunction to the uploadStarted event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired just after the POST request was sent.

detachUploadAborted

Detaches event handler fnFunction from the uploadAborted event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

detachUploadCompleted

Detaches event handler fnFunction from the uploadCompleted event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

detachUploadProgressed

Detaches event handler fnFunction from the uploadProgressed event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

detachUploadStarted

Detaches event handler fnFunction from the uploadStarted event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

downloadItem

Starts the process of downloading a file.

sap.m.upload.Uploader.extend

Creates a new subclass of class sap.m.upload.Uploader with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Element.extend.

fireUploadAborted

Fires event uploadAborted to attached listeners.

fireUploadCompleted

Fires event uploadCompleted to attached listeners.

fireUploadProgressed

Fires event uploadProgressed to attached listeners.

fireUploadStarted

Fires event uploadStarted to attached listeners.

getDownloadUrl

Gets current value of property downloadUrl.

URL where the next file is going to be download from.

getHttpRequestMethod

Gets current value of property httpRequestMethod.

HTTP request method chosen for file upload.

Default value is Post.

sap.m.upload.Uploader.getMetadata

Returns a metadata object for class sap.m.upload.Uploader.

getUploadUrl

Gets current value of property uploadUrl.

URL where the next file is going to be uploaded to.

getUseMultipart

Gets current value of property useMultipart.

This property decides the type of request. If set to "true", the request gets sent as a multipart/form-data request instead of file only request.

Default value is false.

setDownloadUrl

Sets a new value for property downloadUrl.

URL where the next file is going to be download from.

When called with a value of null or undefined, the default value of the property will be restored.

setHttpRequestMethod

Sets a new value for property httpRequestMethod.

HTTP request method chosen for file upload.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Post.

setUploadUrl

Sets a new value for property uploadUrl.

URL where the next file is going to be uploaded to.

When called with a value of null or undefined, the default value of the property will be restored.

setUseMultipart

Sets a new value for property useMultipart.

This property decides the type of request. If set to "true", the request gets sent as a multipart/form-data request instead of file only request.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

terminateItem

Attempts to terminate the process of uploading the specified file.

sap.m.upload.Uploader.uploadFile

Starts function for uploading one file object to given url. Returns promise that resolves when the upload is finished or rejects when the upload fails.

uploadItem

Starts the process of uploading the specified file.

attachUploadAborted

Attaches event handler fnFunction to the uploadAborted event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired when an XHR request reports its abortion.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.upload.Uploader itself

attachUploadCompleted

Attaches event handler fnFunction to the uploadCompleted event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired when an XHR request reports successful completion of upload process.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.upload.Uploader itself

attachUploadProgressed

Attaches event handler fnFunction to the uploadProgressed event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired every time an XHR request reports progress in uploading.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.upload.Uploader itself

attachUploadStarted

Attaches event handler fnFunction to the uploadStarted event of this sap.m.upload.Uploader.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.upload.Uploader itself.

The event is fired just after the POST request was sent.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.upload.Uploader itself

detachUploadAborted

Detaches event handler fnFunction from the uploadAborted event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachUploadCompleted

Detaches event handler fnFunction from the uploadCompleted event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachUploadProgressed

Detaches event handler fnFunction from the uploadProgressed event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachUploadStarted

Detaches event handler fnFunction from the uploadStarted event of this sap.m.upload.Uploader.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

downloadItem

Starts the process of downloading a file.

Param Type DefaultValue Description
oItem sap.m.upload.UploadSetItem

Item representing the file to be downloaded.

aHeaderFields sap.ui.core.Item[]

List of header fields to be added to the GET request.

bAskForLocation boolean

True if the location to where download the file should be first queried by a browser dialog.

sap.m.upload.Uploader.extend

Creates a new subclass of class sap.m.upload.Uploader with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Element.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

fireUploadAborted

Fires event uploadAborted to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

item sap.m.upload.UploadSetItem

The item that is going to be deleted.

fireUploadCompleted

Fires event uploadCompleted to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

item sap.m.upload.UploadSetItem

The item that was uploaded.

fireUploadProgressed

Fires event uploadProgressed to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

item sap.m.upload.UploadSetItem

The item that is being uploaded.

loaded int

The number of bytes transferred since the beginning of the operation. This doesn't include headers and other overhead, but only the content itself

total int

The total number of bytes of content that will be transferred during the operation. If the total size is unknown, this value is zero.

fireUploadStarted

Fires event uploadStarted to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

item sap.m.upload.UploadSetItem

The item that is going to be uploaded.

getDownloadUrl

Gets current value of property downloadUrl.

URL where the next file is going to be download from.

getHttpRequestMethod

Gets current value of property httpRequestMethod.

HTTP request method chosen for file upload.

Default value is Post.

sap.m.upload.Uploader.getMetadata

Returns a metadata object for class sap.m.upload.Uploader.

getUploadUrl

Gets current value of property uploadUrl.

URL where the next file is going to be uploaded to.

getUseMultipart

Gets current value of property useMultipart.

This property decides the type of request. If set to "true", the request gets sent as a multipart/form-data request instead of file only request.

Default value is false.

setDownloadUrl

Sets a new value for property downloadUrl.

URL where the next file is going to be download from.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sDownloadUrl string

New value for property downloadUrl

setHttpRequestMethod

Sets a new value for property httpRequestMethod.

HTTP request method chosen for file upload.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Post.

Param Type DefaultValue Description
sHttpRequestMethod sap.m.upload.UploaderHttpRequestMethod Post

New value for property httpRequestMethod

setUploadUrl

Sets a new value for property uploadUrl.

URL where the next file is going to be uploaded to.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sUploadUrl string

New value for property uploadUrl

setUseMultipart

Sets a new value for property useMultipart.

This property decides the type of request. If set to "true", the request gets sent as a multipart/form-data request instead of file only request.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Param Type DefaultValue Description
bUseMultipart boolean false

New value for property useMultipart

terminateItem

Attempts to terminate the process of uploading the specified file.

Param Type DefaultValue Description
oItem sap.m.upload.UploadSetItem

Item representing the file whose ongoing upload process is to be terminated.

sap.m.upload.Uploader.uploadFile

Starts function for uploading one file object to given url. Returns promise that resolves when the upload is finished or rejects when the upload fails.

Param Type DefaultValue Description
oFile File Blob

File or Blob object to be uploaded.

sUrl string

Upload Url.

aHeaderFields sap.ui.core.Item[]

Collection of request header fields to be send along.

uploadItem

Starts the process of uploading the specified file.

Param Type DefaultValue Description
oItem sap.m.upload.UploadSetItem

Item representing the file to be uploaded.

aHeaderFields sap.ui.core.Item[]

Collection of request header fields to be send along.