File Export

hi, in old CEP we were able to export the current active document as a file without a file picker just by using:

var outputFile = new File(outputPath);
docRef.exportDocument(outputFile, ExportType.SAVEFORWEB, options)

It is possible to export a file and save it in for example temp folder?

I’ve tried this code without any luck:

const tempFolder = await lfs.getTemporaryFolder();
const tempFile = await tempFolder.createFile('temp.png');
document.save(tempFile);

I fixed it using activeDocument

My code:

const uxp = require('uxp');
const PS = require('photoshop');
const lfs = uxp.storage.localFileSystem;
const activeDoc = PS.app.activeDocument;

async function exportFile() {
  const tempFolder = await lfs.getTemporaryFolder();
  const tempFile = await tempFolder.createFile('temp_dbg.png');
  console.log(tempFile.nativePath);
  activeDoc.save(tempFile);
}

document.getElementById("btnPopulate").addEventListener("click", exportFile);