how should I send the "Object Blob" from Java script to an Activity in pega
Hi All,
I have a scenario where I have a Blob data of type content which is actually a zip content which i am getting from below code same I am able to download on my local :
zip.generateAsync({type: 'blob'}) .then(content => { console.log("zip file"); console.log(content);
saveAs(content, "package.zip")-- This statement is saving that package on local.
I want to send this content to a Pega activity where in Java code I want to read it . I tried below code
var sUrl = new SafeURL("Data-WorkAttach-File.UploadReactFUComp"); var formData = new FormData(); formData.put = FormData.prototype.append; formData.copy = SafeURL.prototype.copy; sUrl.put("ZipFile",content); pega.u.d.asyncRequest("POST", sUrl, '' , formData);
In activity I am trying reading using below code.
Hi All,
I have a scenario where I have a Blob data of type content which is actually a zip content which i am getting from below code same I am able to download on my local :
zip.generateAsync({type: 'blob'}) .then(content => { console.log("zip file"); console.log(content);
saveAs(content, "package.zip")-- This statement is saving that package on local.
I want to send this content to a Pega activity where in Java code I want to read it . I tried below code
var sUrl = new SafeURL("Data-WorkAttach-File.UploadReactFUComp"); var formData = new FormData(); formData.put = FormData.prototype.append; formData.copy = SafeURL.prototype.copy; sUrl.put("ZipFile",content); pega.u.d.asyncRequest("POST", sUrl, '' , formData);
In activity I am trying reading using below code.
so that later I want to upload this file to static content location or to another server location before that I was trying to read this file content in the calling Activity using below code and sending this to browser but this is not working.
try { byte[] byteArray=(byte[])tools.getParameterPage().getParameterValue("ZIPFile"); oLog.infoForced("ByteArray: " + byteArray); HashStringMap aMap = new HashStringMap();
aMap.put( "ContentDisposition", "attachment;filename=\"test.zip\"" ); aMap.put( "ContentType", "application/attachment" );
//String result=tools.sendFile(byteArray,"test",false,aMap,true); tools.sendFile(byteArray,"Test.zip",false,aMap,true); } catch(Exception e) { throw new PRRuntimeException(e);
}
but here this oLog statement is coming as null. which means that blob object is not coming here properly.
Please suggest how should I send the "Object Blob" from Java script to an Activity in pega.
Appreciate your early help.
Thanks-
Ruchi