Skip to Content

Using UploadCollection control in Hybrid app for iOS

Hi,

I have created a Hybrid UI5 application using HAT, i am using UploadCollection control in one of the screen, the control works fine on a Browser (Desktop and Phone) but does not work when wrapped in Kapsel and Cordova. When i click on the 'Add' button it does nothing, no error on console.

Note: I have added the required Privacy Keys in my Info.plist

Is there something else i need to configure to open the Photo Library or the Camera from UploadCollection control?

this is my UploadCollection code

new sap.m.UploadCollection("UploadCollection", {
					multiple: true,
					uploadUrl: that.getView().getModel("mainServiceModel").sServiceUrl + "/AttachmentsSet",
					numberOfAttachmentsText: "Attachments (0)",
					terminationEnabled: false,
					fileType: ["jpg", "txt", "ppt", "docx", "xls", "pdf", "png"],
					mimeType: ["image/jpg", "image/jpeg", "application/pdf"],
					noDataText: "No Data",
					beforeUploadStarts: function(e) {
						sap.ui.core.BusyIndicator.show(0);
						// Header Slug
						var oCustomerHeaderSlug = new sap.m.UploadCollectionParameter({
							name: "slug",
							value: workorderId + "/" + lineItem + "/" + e.getParameter("fileName") + "/Description"
						});
						if (sap.hybrid === null) {
							var oCustomerHeaderHybrid = new sap.m.UploadCollectionParameter({
								name: "X-SUP-APPCID",
								value: sap.hybrid.SMP.AppContext.applicationConnectionId
							});
							e.getParameters().addHeaderParameter(oCustomerHeaderHybrid);
                        }   
						e.getParameters().addHeaderParameter(oCustomerHeaderSlug);


					},
					uploadComplete: function(e) {
						sap.m.MessageToast.show("Upload Completed");
						this.destroyItems();
						this.bindAggregation("items", {
							path: "mainServiceModel>/AttachmentsSet",
							filters: [new sap.ui.model.Filter("ObjectId", sap.ui.model.FilterOperator.EQ, workorderId),
								new sap.ui.model.Filter("Item", sap.ui.model.FilterOperator.EQ, lineItem)
							],
							template: new sap.m.UploadCollectionItem({
								enableEdit: true,
								enableDelete: true,
								visibleEdit: true,
								visibleDelete: true,
								fileName: "{mainServiceModel>Filename}",
								url: "{mainServiceModel>AbsoluteUrl}",
								mimeType: "{mainServiceModel>ContentType}"
							})
						});
						var aItems = sap.ui.getCore().byId("UploadCollection").getItems();
						sap.ui.getCore().byId("UploadCollection").setNumberOfAttachmentsText("Attachments (" + aItems.length + ")");
						sap.ui.core.BusyIndicator.hide();
						this.focus();
					},
					change: function(e) {
						var oUploadCollection = e.getSource();
						// Header Token
						var oCustomerHeaderToken = new sap.m.UploadCollectionParameter({
							name: "x-csrf-token",
							value: secToken
						});
						oUploadCollection.addHeaderParameter(oCustomerHeaderToken);
					}
				})

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 30 at 10:36 AM

    Hi Naveen,

    have you activated and plugged in the cordova-plugin for camera, access file and capture?

    If you don't integrated the plugins into your UI5-app it doesn't work...

    Add comment
    10|10000 characters needed characters exceeded