9 Replies Latest reply on Oct 10, 2011 7:19 AM by Benedict Kennedy

    FTP issue

      I am trying to upload a file to a FTP server, to no avail.

       

      Code I am using is:

          fileTransfer.source = url('file://\\Program Files\\RhoElements\\file__0\\0000000000000001.db');
         fileTransfer.destination = url('ftp://test:test@169.254.2.2/res.db');
          fileTransfer.transfer();

       

      I have installed a FTP client on the terminal, which works fine with the same configuration. Hence FTP server, user/passwd, filesystems and connectivity are all OK.

      However, RhoElements does not even contact FTP server, as can be seen on FTP's log screen.

      FYI, FTP server is Filezilla and connectivity is Active Sync. But I don't really think problem lays there! Remember, the other FTP client works fine.

       

      Am I missing something?

      thanks in advance!

       

      Pls find attached log.txt and plugin.xml, in case this helps.

        • Re: FTP issue
          Robert Galvin

          Juan –

           

          You may want to add the transferEvent and see what comes back in the error information. You may also want to add the port to the destination url:

           

          = url('ftp://test:test@169.254.2.2:21/res.db');

           

           

           

          What is the size of the file?

           

          Rob

          • Re: FTP issue
            Benedict Kennedy

            The reason why your code isn't working is because the argument needs to be surrounded by quotation marks. Changing your code to this should fix the problem:

                 fileTransfer.source = "url('file://\\Program Files\\RhoElements\\file__0\\0000000000000001.db')";

                 fileTransfer.destination = "url('ftp://test:test@169.254.2.2/res.db')";

                 fileTransfer.transfer();

             

            I have also found a similar mistake in the examples section of the FileTransfer module page in the help file, this will be fixed by the next release of RhoElements.

             

            Best regards,

            Ben

              • Re: FTP issue

                Thanks!

                Well, I actually had to enclose in quotes the whole thing.

                 

                But then again despite it did connect, it did not send anything.

                I tried then to use a path without blanks, and now, yes it worked. And event function was properly invoked.

                 

                So, I reckon there is one more bug to fix: blanks seem not being supported on paths.

                 

                This is the source code:

                function FTPResult(res)

                {

                    alert(res);

                }

                 

                function FTPtransfer(direction, fileloc, filerem, server, user, passwd)

                   {

                        fileTransfer.createFolders = true;

                        fileTransfer.overWrite = true;

                        fileTransfer.username = user;

                        fileTransfer.password = passwd;

                        fileTransfer.transferEvent = "FTPResult('%s')";

                       fileTransfer.source = "url('file://\\Application\\0000000000000001.db')";  // NO blanks on it

                        fileTransfer.destination = "url('ftp://169.254.2.2:21/res.db')";

                        fileTransfer.transfer();   

                   }

                  • Re: FTP issue

                    Hi again,

                     

                    I have written a more flexible generic function someone may find useful:

                     

                    function FTPtransfer(direction, fileloc, filerem, server, user, passwd)

                       {

                       var txtSource;

                       var txtDest;

                      

                            if ( direction == "UP" )

                                {

                                txtSource = "url('file://" + fileloc + "')";

                                txtDest = "url('ftp://" + server + "/" + filerem + "')";

                                }

                            else

                                {

                                txtDest = "url('file://" + fileloc + "')";

                                txtSource = "url('ftp://" + server + "/" + filerem + "')";

                                }

                           

                            fileTransfer.createFolders = 'True';

                            fileTransfer.overWrite = 'True';

                            fileTransfer.username = user;

                            fileTransfer.password = passwd;

                            fileTransfer.transferEvent = "FTPResult('%s')";

                            fileTransfer.source = txtSource;

                            fileTransfer.destination = txtDest;

                            fileTransfer.transfer();   

                       }

                     

                    I have tested that fileTransfer.createFolders = 'True' seems not to work.

                    If I call my function with a remote filename containing a non-existant folder, it does not create it and comes out with error code 12003.