I’m storing the pdf (or .doc, .xls) inside a blob (media field) that gets uploaded from the browser. Here is the callback that does the record storage:
function attachment_stream(callbackArray) {
if(callbackArray.length > 0) {
var recs = 0;
var fileObj = plugins.file.convertToJSFile(callbackArray[0])
if(fileObj.size() > 0) {
var fsAttached = forms.attached_forms_incl.foundset;
fsAttached.newRecord();
fsAttached.fgn_record_id = forms.asmt_base_form_i.asmt_assessment_id;
fsAttached.fgn_table_name = "assessment";
fsAttached.fat_item_blob = fileObj.getBytes();
fsAttached.fat_item_text = fileObj.getName();
fsAttached.fat_item_type = fileObj.getContentType();
databaseManager.saveData(fsAttached.getSelectedRecord());
recs = databaseManager.getFoundSetCount(fsAttached);
vSelectInfo = recs.toString(10) + " attachment(s). ";
fileObj = null; // clear it out again (reduce memory?)
} // (bytes.length > 0)
} // (callbackArray.length > 0)
}
Now I am trying to push it back when the user clicks on it from a tableview list (a download button), but this does not seem to work (below). It executes, but nothing happens on the browser end. Can you correct this code?
function onClick_downloadForm(event) {
var fileSuffix = "";
var fileObj = plugins.file.createTempFile(fat_item_text,fileSuffix) // fat_item_text looks like "filename.pdf"
var proceed_B = plugins.file.writeFile(fileObj,fat_item_blob,fat_item_type)
}
Thanks,
Don