I would like to create subfolders and save images in them.
I want to avoid to have the users to constantly be confronted with a folder picker dialog like getFolder()
I have set the local file permission to “fullAccess”, like adressed here.
With the help of the Alchemist plugin, I was able to import a layer via a sessionToken:
async function importLayer(){
const result = await batchPlay(
[
{
_obj: "placeEvent",
null: {
_path: await tokenify("C:/STAPELVERARBEITUNG/Hintergrund_Artikel_Verlauf2000x2000MitteHeller.jpg"),
_kind: "local"
},
freeTransformCenterState: {
_enum: "quadCenterState",
_value: "QCSAverage"
},
offset: {
_obj: "offset",
horizontal: {
_unit: "pixelsUnit",
_value: 0
},
vertical: {
_unit: "pixelsUnit",
_value: 0
}
},
_options: {
dialogOptions: "dontDisplay"
}
}
],
{}
);
}
The “tokenify” function looks like this:
async function tokenify(url){
return fs.createSessionToken(await fs.getEntryWithUrl("file:" + url));
}
So naturally, I would think something like the followiing “should” work, but it doesnt, at least for me:
async function tokenifyFolder(url){
return fs.createSessionToken(await fs.getEntryWithUrl("folder:" + url));
}
Am I doing something wrong? I can only find references to the “getFolder()” function to get a valid token. Thank you for your patience and help!
I have wrapped the call of the tokenifyPath function into a try catch block, this is what I got. I have a hunch that the “file:///folder:/” part is not correct: