I want to save an image as a Photoshop Raw file to the temporary folder. I seem to have working code, except it fails as requiring a file token - but why should I need this if I’m saving to the plugins temporary folder? The API documentation seems to indicate that tokens should not be required for the temporary folder.
My code, I’m using a try catch as the debugger fails to catch the error message returned
Batch play does not throw an error AFAIK. It return an array of responses for each descriptor. If there’s an error, last item of that response array (matching descriptor index) will hold the error message. If you want it to throw an error, you have to do it yourself.
Check this awesome snippet how to continue BP on error and there you can find how error is handled. And one comment bellow I posted a bit improved part of that snippet.
Aye thanks. BP not throwing errors to the debugger is a bit confusing to start with, but try-catch handles them fine - although a bit more official documentation on that would have been helpful! I found that after digging thorugh posts on here.
However that the BP call fails because it says it has an invalid token when writing to the temporary folder using the above code doesn’t make much sense. This page
You can use the fs object to access a temporary folder or your plugin’s own folder immediately, or request access to user folders by showing a file picker:
// These require no user interaction:
const tempFolder = await fs.getTemporaryFolder();
And yet, BP fails with Error: invalid file token used when I try to do so,
I was in the same situation as you and had to experiment around, because the documentation was not very helpful. In the end I found out that I had to create a session token. Hopefully this is useful for someone: