You need to sign in to do that
Don't have an account?
prashant1.393935347365481E12
Read zip attachments
Hi,
Please suggest how can I read a zip attachment from the VF page. The attachment consists of some text files. Currently I am reading it via zip.js library but it gives a cross domain accessibility error since the attachments are in a different sub domain.
Please suggess a way out!!
Please suggest how can I read a zip attachment from the VF page. The attachment consists of some text files. Currently I am reading it via zip.js library but it gives a cross domain accessibility error since the attachments are in a different sub domain.
Please suggess a way out!!
In order to read the Read zip attachments, Please include JSzip library in the javascript function.
Here is the example of the javascript code snippet-
function viewContent(){
var zip = null;
var zipFileName = null;
var zipFileNames = null;
data = "{!contentAsText}";
zip = new JSZip(data, {base64:true});
zipFileName = 'files.zip';
zipFileNames = [];
for(var zipfileName in zip.files){
zipFileNames.push(zipfileName);
if(zipfileName == 'index.html'){
var file = zip.files[zipfileName];
var data = file.data;
document.getElementById('contentdiv').innerHTML = data;
//var data = JSZipBase64.encode(file.data);
}
}
n controller --
public String contentAsText {get;set;}
List<Attachment> atts = [Select Id, Body from Attachment where name='files.zip' limit 1];
contentAsText = EncodingUtil.base64Encode(atts[0].Body);
Hope this helps.