A basic implementation for uploading and downloading one or multiple files.
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()
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. |
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. |
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. |
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. |
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. |
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. |
Method | Description |
---|---|
attachUploadAborted |
Attaches event handler When called, the context of the event handler (its The event is fired when an XHR request reports its abortion. |
attachUploadCompleted |
Attaches event handler When called, the context of the event handler (its The event is fired when an XHR request reports successful completion of upload process. |
attachUploadProgressed |
Attaches event handler When called, the context of the event handler (its The event is fired every time an XHR request reports progress in uploading. |
attachUploadStarted |
Attaches event handler When called, the context of the event handler (its The event is fired just after the POST request was sent. |
detachUploadAborted |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachUploadCompleted |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachUploadProgressed |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachUploadStarted |
Detaches event handler 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
|
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 |
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 |
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 |
setHttpRequestMethod |
Sets a new value for property httpRequestMethod. HTTP request method chosen for file upload. When called with a value of Default value is |
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 |
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 Default value is |
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. |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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. |
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 |
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. |
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. |
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. |
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. |
Gets current value of property downloadUrl.
URL where the next file is going to be download from.
Gets current value of property httpRequestMethod.
HTTP request method chosen for file upload.
Default value is Post
.
Gets current value of property uploadUrl.
URL where the next file is going to be uploaded to.
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
.
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 |
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 |
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 |
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 |
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. |
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. |
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. |