Skip to Content
0
Jul 11, 2019 at 09:31 AM

sap.m.UploadCollection Issue while Uploading\Downloading .msg file type in Chrome Browser?

532 Views Last edit Jul 16, 2019 at 07:08 AM 2 rev

Same file and Same file Type Upload and Download is working properly in IE11. But in Chrome(75.0) showing error.

Not able to identify whether it has to corrected from Front end side or Backend gateway side.

Error Message while Opening .msg file from chrome downloaded.

error-message-while-opening.png

File Properties are different like Custom tab is not there for when u download from Chrome.(Custom Data tab is there for all .msg file is we save from outlook)

File Properties when downloaded from IE

file-properties-ie11.png

File Properties when downloaded from Chrome

file-properties-chrome.png

View Code

<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns="sap.m">
	<Dialog showHeader="false" title="{i18n>detailPage_iceMatrixTab_Attachments}" contentHeight="320px" contentWidth="650px">
		<Page id="AttachGlobal" showHeader="false" showNavButton="false">
			<content>
				<UploadCollection id="UploadCollectionGl" maximumFilenameLength="80" maximumFileSize="10" multiple="false" sameFilenameAllowed="false"
					instantUpload="false" noDataDescription="{i18n>detailPage_Button_Upload_noDescMsg}" change="onChange" fileDeleted="onFileDeleted"
					filenameLengthExceed="onFilenameLengthExceed" fileSizeExceed="onFileSizeExceed" typeMissmatch="onTypeMissmatch"
					uploadComplete="onUploadComplete" beforeUploadStarts="onBeforeUploadStarts" 
					numberOfAttachmentsText="{i18n>detailPage_iceMatrixTab_Attachments}"></UploadCollection>
			</content>
			<footer>
				<OverflowToolbar>
					<ToolbarSpacer/>
					<Button id="idUploadGlBtn" text="{i18n>detailPage_Button_Upload}" press="onStartUploadGl" enabled="true"/>
					<Button text="{i18n>detailPage_Button_Upload_Close}" press="onAttachmentsGlClose"/>
				</OverflowToolbar>
			</footer>
		</Page>
	</Dialog>
</core:FragmentDefinition>

Controller Code for file Uploading

var a = "/sap/opu/odata/sap/Z_XYZ_PD_DB_SRV";
												var f = {
													headers: {
														"X-Requested-With": "XMLHttpRequest",
														"Content-Type": "application/atom+xml",
														"DataServiceVersion": "2.0",
														"X-CSRF-Token": "Fetch",
													},
													requestUri: a,
													method: "GET"
												};
												var oHeaders;
												var sUrl = "/sap/opu/odata/sap/Z_XYZ_PD_DB_SRV;mo/AttachmainSet(SAP__Origin='" + window.oGlobalSysAlias +
													"',Filename='" + file.name + "')/AttachmentDetailsSet";
												OData.request(f, function (data, oSuccess) {
													var oToken = oSuccess.headers["x-csrf-token"];
													oHeaders = {
														"x-csrf-token": oToken,
														"slug": "U||" + window.viewFlag + "||G||" + window.oPrKey + "||" + $.sap.oGlobalOrderNo + "|| ||" + file.name,
														"PrRangeKey": window.oPrKey,
														"PrTypeKey": ""
													};
													/****************To Fetch CSRF Token*******************/


													/*******************To Upload File************************/
												          
													var filetype = file.type;
													var oURL = sUrl;
													var base64_marker = 'data:' + filetype + ';base64,';


													
													var reader = new FileReader();
													reader.onload = (function (sFilename) {
														return function (evt) {
															var base64Index = evt.target.result.indexOf(base64_marker) + base64_marker.length;
															var base64 = evt.target.result.substring(base64Index);
															jQuery.ajax({
																type: 'POST',
																url: oURL,
																headers: oHeaders,
																cache: false,
																contentType: filetype,
																processData: false,
																data: base64,
																success: function (data) {
																	if (oPrRangeFlag === true) {
																		window.oPrKey = data.childNodes[0].childNodes[6].childNodes[1].firstChild.nodeValue;
																		AppService.getSharedModel().getProperty(window.oPrKeyPath).PrKey = data.childNodes[0].childNodes[6].childNodes[1].firstChild.nodeValue;														
																		AppService.getSharedModel().refresh(true);
																		oPrRangeFlag = false;
																	}
																	that.onAttachmentsGlClose();
																	busyDialog.close();
																	busyDialog.setVisible(false);
																	if (data.childNodes[0].childNodes[6].childNodes[4].firstChild.nodeValue === "Uploaded Successfully") {
																		sap.m.MessageToast.show(I18nService.getResourceBundle().getText(
																			"detailPage_PriceMatrixTab_UploadSuccess"));
																		var oPrRangeKey = window.oPrKey;
																		var oPrTypeKey = " ";
																		var oIdentifier = window.viewFlag;
																		var oReadType = "RG";
																		MaintainPriceService.getAttachmentsGl(oPrRangeKey, oPrTypeKey, oIdentifier, oReadType);
																	}
																	if (data.childNodes[0].childNodes[6].childNodes[4].firstChild.nodeValue === "Upload Failed") {
																		sap.m.MessageToast.show(I18nService.getResourceBundle().getText("detailPage_PriceMatrixTab_UploadFailed"));
																	}


																},
																error: function (data) {
																	that.onAttachmentsGlClose();
																	busyDialog.close();
																	busyDialog.setVisible(false);
																	sap.m.MessageToast.show(I18nService.getResourceBundle().getText("detailPage_PriceMatrixTab_UploadFailed"));
																}
															});
														};
													})(file);
													reader.readAsDataURL(file);
												});