Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

file uploader script

Participant ,
Feb 20, 2014 Feb 20, 2014

I am new to Photshop scripting. I am contempalting a sript which will upload files to a local server as well as a remote server.

Is this idea execuatable with the scripting allowances built in Photoshop CC?

TOPICS
Actions and scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 20, 2014 Feb 20, 2014

Yes, you can either save the file from within Photoshop, if the document is open, or you can copy the file to a server.  This is outlined in the ExtendScript Toolkit SDK.

The code would look something like this:

var file = new File('/c/filepath/file.jpg')

file.copy('/d/newPath/file.jpg')

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 20, 2014 Feb 20, 2014

Thanks for the quick response!

Taking a step further, Can the the script work in tandom with a dialog box will allow to change the destiantion folder on the local and remote server?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2014 Feb 20, 2014

Yes, you can write the code to open the open dialog UI.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2014 Feb 20, 2014

Here's a sample ui that I created for my work.  I just click on one of the buttons at the top and it brings up the folder dialog box that for saving different versions of the files that I'm going to process.

ui.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2014 Feb 20, 2014
LATEST

ojodegato wrote:

I am new to Photshop scripting. I am contempalting a sript which will upload files to a local server as well as a remote server.

Is this idea execuatable with the scripting allowances built in Photoshop CC?

If by local server you mean the machine you on and running Photoshop on there is no upload you can save or copy files to the servers tree.  Remote server would require a remote share or some other type of file transfer like FTP.   I do not think Adobe grantee's that Photoshop save will work on remote shared disk. I think I remember reading threads on that subject. I also have not seen a Photoshop FTP script that works.  I have search for  Photoshop FTP scripts.  I also look at how  the Bridge FTP  things like web galleries and it uses a DLL not a script.  Photoshop does support socket connections and I have connected to HTTP Port 80 on servers and retrieved files.  But I have never seen a Photoshop script that connects to an FTP port that works.  Photoshop sample script the uses a sockets connection wares the the can time out.

// Copyright 2007.  Adobe Systems, Incorporated.  All rights reserved.

// This script demonstrates how to download images from a web server using the Socket object.

// Note: Socket.read() parameter & behavior

// Socket.read() will read or time out. It may not read all data from server.

// Socket.read(999999) will read 999999 bytes, or timeout, or socket will be

// closed by the server.

// Settings

#target photoshop

app.bringToFront(); // bring top

if("en_US" == $.locale) { // display only US build

          alert("This sample script shows how to download images from a web server using the Socket object.");

}

// Remove header lines from HTTP response

function removeHeaders(binary)

{

          var bContinue = true ; // flag for finding end of header

          var line = "";

          var nFirst = 0;

          var count  = 0;

          while (bContinue) {

                    line = getLine(binary) ; // each header line

                    bContinue = line.length >= 2 ;  // blank header == end of header

                    nFirst = line.length + 1 ;

                    binary = binary.substr(nFirst) ;

          }

          return binary;

}

// Get a response line from the HTML

function getLine(html)

{

          var line = "" ;

          for (var i = 0; html.charCodeAt(i) != 10; i++){ // finding line end

                    line += html ;

          }

          return line ;

}

var socket = new Socket;

var html = "";

if (socket.open("www.adobe.com:80")){

          socket.write("GET /index.html HTTP/1.0\n\n");

          html = socket.read(9999999);

          socket.close();

}

var aImg = html.match(/src=\"\/images\/(.*?)\"/g);  //  src="/images/~~~"

if (null != aImg) { // parsed image tags

          for (var i=0; i < aImg.length; i++) {

                    try{

                              var str = aImg;

                              var sImg = str.substring(5, str.length-1); // remove "src=" & ["]

                              var f = File("~/socket_sample_" + i + sImg.substr(sImg.length-4)); // 4 = .gif or .jpg

                              f.encoding  = "binary";  // set binary mode

                              f.open("w");

                              if (socket.open("www.adobe.com:80", "binary")){

                                        socket.write("GET " + sImg +" HTTP/1.0\n\n"); // Adobe's site image link starts with "/"

                                        var binary = socket.read(9999999);

                                        binary = removeHeaders(binary);

                                        f.write(binary);

                                        socket.close();

                              }

                              f.close();

                              app.open(f); // Open files in Photoshop

                              f.remove();  // Remove temporary downloaded files

                    }catch(e){

                    }

          }

}

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines