Skip to content

Instantly share code, notes, and snippets.

@tokyosheep
Last active April 28, 2024 01:15
Show Gist options
  • Select an option

  • Save tokyosheep/70559c90f2cd29baefa8f144eb9618d5 to your computer and use it in GitHub Desktop.

Select an option

Save tokyosheep/70559c90f2cd29baefa8f144eb9618d5 to your computer and use it in GitHub Desktop.
save cloud doc on Photoshop
(function() {
var idsave = charIDToTypeID( "save" );
var desc266 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc267 = new ActionDescriptor();
var idcloudPSDFormat = stringIDToTypeID( "cloudPSDFormat" );
desc266.putObject( idAs, idcloudPSDFormat, desc267 );
var idassetRef = stringIDToTypeID( "assetRef" );
//here is local id and filepath on cloud doc. replace the local id with yours
desc266.putString( idassetRef, {
"local_id":"urn:uid:local:000000-0000-oooo-0000-dooooooo",
"path":"/cloud-content/tokyo.psdc",
"display_name":"tokyo.psdc","repository_id":"~",
"preference":
2} );
var idmimeType = stringIDToTypeID( "mimeType" );
desc266.putString( idmimeType, "document/vnd.adobe.cpsd+dcx" );
var idIn = charIDToTypeID( "In " );
/*
modyfied filePath dapting for both OS.
here is cloud file path as well. tokyo.psdc is filename
on Mac OS you may find problem this type of filePath "C:\\cloud-content\\repo:~\\cloud-content\\tokyo.psdc"
*/
desc266.putPath( idIn, new File( "/cloud-content/tokyo.psdc" );
var idDocI = charIDToTypeID( "DocI" );
desc266.putInteger( idDocI, 82 );
var idLwCs = charIDToTypeID( "LwCs" );
desc266.putBoolean( idLwCs, true );
var idsaveStage = stringIDToTypeID( "saveStage" );
var idsaveStageType = stringIDToTypeID( "saveStageType" );
var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
desc266.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
executeAction( idsave, desc266, DialogModes.NO );
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment