CREATE COLUMN TABLE "DEMOUSER"."ATTACHMENT"(
"ATTACHMENTID" INTEGER CS_INT,
"ATTACHMENTNAME" NVARCHAR(100),
"ATTACHMENTCONTENT" CLOB MEMORY THRESHOLD 1000000,
PRIMARY KEY (
"ATTACHMENTID"
)
) UNLOAD PRIORITY 5 AUTO MERGE;
service namespace "application"
{
"DEMOUSER"."ATTACHMENT" as "ATTACHMENT";
}
schema_name="DEMOUSER";
{
"exposed": true,
"authentication": [{
"method": "Basic"
}],
"force_ssl": false,
"enable_etags": true,
"prevent_xsrf": false,
"anonymous_connection": null,
"cors": [{
"enabled": false
}],
"cache_control": "no-cache, no-store"
}
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("attachment.attachment.controller.View1", {
onInit: function () {
var oStorage = jQuery.sap.storage(jQuery.sap.storage.Type.local);
oStorage.clear();
},
seePreview: function (oEvent) {
var oStorage = jQuery.sap.storage(jQuery.sap.storage.Type.local);
if (oStorage.get("oAttachment") !== null) {
this.getView().byId("img").setSrc(oStorage.get("oAttachment").ATTACHMENTCONTENT);
} else {
sap.m.MessageToast.show("Kindly Upload the Attachment First");
}
},
handleUploadPress: function (oEvent) {
var fileUploader = this.getView().byId("fileUploader");
var id = this.getView().byId("input").getValue();
var attachid = parseInt(id);
var fileStore = jQuery.sap.domById(fileUploader.getId() + "-fu").files[0];
this.upload(fileStore, fileStore.name,attachid);
},
upload: function (fileStore, docName,attachid) {
this.attach = {};
if (fileStore) {
var fileReader = new FileReader();
var selectedFile = fileStore;
fileReader.onload = function (oEvent) {
var base64 = oEvent.target.result;
var oStorage = jQuery.sap.storage(jQuery.sap.storage.Type.local);
var attachment = {
"ATTACHMENTID": attachid,
"ATTACHMENTNAME": docName,
"ATTACHMENTCONTENT": base64
};
this.attach = attachment;
oStorage.put("oAttachment", attachment);
};
fileReader.readAsDataURL(selectedFile);
sap.m.MessageToast.show("File upload successfully");
} else {
sap.m.MessageToast.show("File upload has been failed");
}
},
onSubmit: function () {
var oModel = this.getView().getModel();
var oStorage = jQuery.sap.storage(jQuery.sap.storage.Type.local);
var attachment = oStorage.get("oAttachment");
oModel.create("/ATTACHMENT", attachment, {
success: function (oData, response) {
sap.m.MessageToast.show("Attacment Uploaded Successfully to XS Backend");
},
error: function (oError) {
sap.m.MessageToast.show("Upload to backend Failed");
}
});
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
3 |