How do you place an image from the local file system using BatchPlay?

Hi folks!

I’m trying to figure out how to place an image into a layer.

Anyone know the proper BatchPlay syntax for placing the image, using a storage Entry?

If I use a string for the _path I get: “invalid file token used,” which I expected.
If I use the Entry, I get: NAPI API failure: String expected.

The latter suggests I’m running the wrong BatchPlay command. Not having any luck finding the proper one. Any suggestions? :slight_smile:

Here’s a code snippet from my plugin:

// Place an image in the document, creating a new layer.
// "asset" is a simple object containing data about the image.
// "asset.file" is the string location of the image on the local file system
MGR.PlaceImage = async function (asset, log) {
	var layer, x, y, w, h, file;

    // SDK.IO.getEntry returns a UXP storage Entry
	file = await SDK.IO.getEntry(asset.file);

    // Build the BatchPlay command
	const cmd = [{
		"_obj": "placeEvent",
		"null": {
			"_path": file, // I've tried both the Entry and the plain string here to no avail
			"_kind": "local"
		"offset": {
			"_obj": "offset",
			"horizontal": {
				"_unit": "pixelsUnit",
				"_value": 0
			"vertical": {
				"_unit": "pixelsUnit",
				"_value": 0
		"_isCommand": true

	// Run the place.
	try {
        // MGR.Batch runs the BatchPlay command.
		await MGR.Batch(cmd);
	} catch (ex) {
		return { error: ex, command: 'PlaceImage', file: asset.file };

Here’s what MGR.Batch looks like:

And this is what the file Entry looks like:

Entry is not enough… you need to make token from entry.

Possible I’m misunderstanding your answer, but the Entry I retrieve is from a dictionary that already has the appropriate persistent access token, previously granted by the user. (And if I don’t have it, there’s a fail state where it will re-request access).

So in this case, the Entry will already have the expected token and permissions shouldn’t be an issue.

I still think that one more conversion step is needed

Gotcha. Not sure what I’d be converting it to though? Do you have an example? I added a screenshot of the file Entry object above, if that helps.

@kerrishotts, know anyone who might have a good idea for me on this?

I think you’re looking for createSessionToken(entry)


Yup, createSessionToken(entry) is your friend :slight_smile:

1 Like

Simon, you’re a hero. And now I understand Jarda’s suggestion! haha Thanks all!