# Export or publish to FTP server



## mhilbush (Mar 31, 2012)

I have my publish to Facebook and Smugmug working well.  Now I'm trying to find a way to do a simple export or publish to an FTP server.  

I found the "Export to FTP from Lightroom" plug-in over on www.presetsheaven.com.  It doesn't seem to work when I try to specify a "Server Path" in the plug-in set up. It works fine if I push the file to the root directory of the FTP server, and when I specify a subfolder, but that's not what I want. 

The error I get is "Unable to upload because Lightroom cannot ascertain if the target destination exists".  Of course, if I look at the plug-in code, it has this wonderful bit of news.  :(


```
else
            [B]-- Not sure if this would every really happen.[/B]
            LrErrors.throwUserError( LOC "$$$/FtpUpload/Upload/Errors/CannotCheckForDestination=Unable to upload because Lightroom cannot ascertain if the target destination exists." )
        end
```

So, before I invest too much time debugging this, I have a couple questions:

- Is anyone else using this plug-in (on Lr4) and, if you specify a Server Path, does it work?

- Is there a better plug-in for doing simple pushes to an FTP server?

Thanks,
Mark


----------



## erro (Mar 31, 2012)

I'm using "FTP Publisher", and that works fine on LR 3, haven't upgraded to LR 4 yet so I can't say how it works there.....

http://www.photographers-toolbox.com/products/ftppublisher.php


----------



## mhilbush (Mar 31, 2012)

Thanks.  I'll give that one a try on Lr4.  It can't work any worse than the one above...

Mark


----------



## mhilbush (Mar 31, 2012)

Not much better with FTP Publisher.




Out of curiosity, are you specifying a Server Path in the dialog box where you configure the FTP server?  If I leave Server Path blank, the upload works.  If I specify a server path (either by typing directly or using the Browse feature), I get the above error.

I would be surprised if this was a problem in the implementation of the SDK class LrFtp; however, i have to wonder, given that it behaves similarly using both plug-ins: "FTP Publisher" and "Export to FTP from Lightroom".  I also suppose it could be an incompatibility issue with Lr4.


----------



## johnbeardy (Mar 31, 2012)

If I recall correctly, that PresetHeaven plugin was (outrageously) little more than a copy of a plugin which Adobe supplied in the LR2 SDK. Why not download the latest SDK and see if the updated plugin works in LR4?

John


----------



## mhilbush (Mar 31, 2012)

johnbeardy said:


> Why not download the latest SDK and see if the updated plugin works in LR4?
> John



Thanks for the suggestion.  Unfortunately, I can't find the 4.0 SDK.  I suspect the updated API spec doesn't come out at the same time as the Lr4 release.

I downloaded the Lr3 SDK.  You're right, the PresetHeaven plugin looks a lot like the ftp_upload example plugin from the SDK.  :nod:

I instrumented the code and ran a few tests.  There's a section of code where they validate that the target directory exists on the remote ftp server.  The sample code iterates over each element in the remote ftp server path to see if it is valid.  It is dying part way through the validation of the server path.

For example, if the remote ftp server path is /usr/www/users/mark/photos, it does an existence check on:
/
/usr
/usr/www
/usr/www/users
/usr/www/users/mark

at which point the ftpConnection:exists() method inexplicably throws an error (it should return "directory").

I'm done for now.  I don't need FTP badly enough to continue messing with this.  <frown>


----------



## erro (Mar 31, 2012)

mhilbush said:


> Not much better with FTP Publisher.
> 
> Out of curiosity, are you specifying a Server Path in the dialog box where you configure the FTP server?  If I leave Server Path blank, the upload works.  If I specify a server path (either by typing directly or using the Browse feature), I get the above error.
> 
> I would be surprised if this was a problem in the implementation of the SDK class LrFtp; however, i have to wonder, given that it behaves similarly using both plug-ins: "FTP Publisher" and "Export to FTP from Lightroom".  I also suppose it could be an incompatibility issue with Lr4.



I'm using FTP Publisher for normal exports. I hit "Export" and select "FTP Publisher" as the export destination instead of the normal "Hard Drive". This allows me to specify a server path (hostname and path) and an optional subpath.


----------



## mhilbush (Apr 1, 2012)

Thanks everyone for your input.  I solved this mystery.

I believe this is a problem in the FTP API in the Lr SDK.  Using a sniffer I examined the way in which the ftpConnection.exists() method determines the existence of a file, directory, etc. on the FTP server.  There is one situation that causes the API to return failure, and there is one case where the API is not documented correctly.

1. If ANY part of the remote path has its permissions set to deny directory listings, ftpConnection.exists() will return failure instead of returning "directory".  For example, in /usr/home/mhilbush/public_html/photos, directory listings on /usr/home are disallowed (which should be the case as this is the directory containing the home directories of everyone on the server).

2. If ANY part of the remote path contains a symbolic link, ftpConnection.exists() will return "symlink", which is not documented in the API.  The sample code does not check for this return.

I don't see too many options at this point.  I guess I'll file a bug report against the API.


----------



## erro (Apr 1, 2012)

Wow, impressive problem research there! You may be a LR beginner, but hardly a Unix/Linux beginner I guess.


----------



## mhilbush (Apr 1, 2012)

Thanks.  I don't too much hands on anymore, but I can still navigate my way through the tools.  :nod:

I tweaked my copy of the Export to FTP plugin code to handle the "symlink" return.  I also suggested to the author that he look to handle the "symlink" condition, as symlinks are fairly common in hosting environments.

And, for now, I worked around the issue with directory listing permissions by just including the relative path in the Server Path setting.  That section of the plug-in code needs to be completely rewritten.  

Bottom line...  Now I can push images to my FTP server!   Woohoo!

I'll also take a look at the FTP Publisher plugin behavior to see which of these issues it was stumbling over.
(I just did this.  FTP Publisher properly handles the symlink issue, but it stumbles on the directory listing permission issue, just like Export to FTP).


----------



## Brainplosion (Sep 30, 2012)

*Thanks*

Hi
Just wanna say thank you for your analysis. I'was searching a solution to publish my work on my zenphoto website. As the zenphoto publish plugin doesn't work (yet...) with my LR, I tried FTP export in the SDK. And get trapped in another error. Your symlink analysis provide me the solution and a workaround waiting the zenphoto plugin new version.
Regards


----------

