8 Replies Latest reply on Aug 26, 2013 5:26 AM by Pietro Francesco Maggi

    FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer.  Getting FileTransfer to work.

    David Miller

      Suggested by Mark Nongkhlawto move to this forum.


      I'm building a WM6.5 app on RhoHub.  I have just introduced some FileTransfer code and added :

      require 'autocomplete/FileTransfer'

      ...in my controller.

      Building in RhoSuite using the simulator is fine but when I try to build for the device (MC55A0) on RhoHub, the app fails with :

      RhoRuby| require_compiled: error : can not find autocomplete/FileTransfer

      APP| App error: no such file to load -- autocomplete/FileTransfer

        • Re: FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer
          David Miller

          I'm using a Ruby implementation as I don't want to expose the credentials as the JS version will do.

           

          But in fact, the code is doing nothing.  Doesn't connect. I don't get any error codes either.

           

          Anyone got any example controller and page that uses the ruby implementation.  The example provided doesn't seem to work.

          • Re: FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer
            Mark Nongkhlaw

            I'm guessing you're trying a build on Rhohub because you don't have the WinMo SDK installed locally?

             

            Not sure what autocomplete/Filetransfer does, do you have the link to the docs?

              • Re: FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer
                David Miller

                autocomplete/FileTransfer is not required.  It's for Eclipse autocomplete only!  I got that from another post.

                Removed it and now...

                 

                Error: uninitialized constant TransferFilesController::FileTransfer

                Trace:

                /Users/david/.rvm/gems/ruby-1.9.3-p392/gems/rhodes-3.5.1.13/lib/framework/rho/rho.rb:1383:in `const_missing'

                /Users/david/Development/StockTake/app/TransferFiles/transfer_files_controller.rb:16:in `uploadFileViaFTPWithCredentials'

                 

                ...of course.

                the require autocomplete was simply masking the problem.

                 

                So need to include/require something I guess.  But what is the question?

                    • Re: FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer
                      David Miller

                      Yes, but it's very much like the example.

                       

                      A Ruby controller...

                       

                      require 'rho/rhocontroller'

                      require 'helpers/browser_helper'

                       

                      class TransferFilesController < Rho::RhoController

                        include BrowserHelper

                       

                        def transferFilesPage

                            render :action => :transferFilesPage

                        end

                       

                        def transferEventListener

                            WebView.execute_js("setTransferResult('"+@params['transferResult']+"');")

                        end

                       

                        def uploadFileViaFTPWithCredentials

                            FileTransfer.transferEvent=url_for(:action => :transferEventListener)

                            FileTransfer.source="url('file://Users/david/Documents/myfile.txt')"

                            FileTransfer.destination="url('ftp://ftpusr:ftppassword@213.nnn.nnn.n:21/myfile.txt')"

                            FileTransfer.transfer 

                        end 

                       

                        def downloadFileWithCredentials

                            FileTransfer.transferEvent=url_for(:action => :transferEventListener)

                            FileTransfer.source="url('ftp://ftpusr:ftppassword@213.nnn.nnn.n:21/myfile.txt')"

                            FileTransfer.destination="url('file://Users/david/Documents/downloaded.txt')"

                            FileTransfer.transfer

                       

                        end

                       

                      end

                       

                       

                      A page to initiate the transfer test...

                       

                      <div data-role="page" data-theme="b">

                       

                        <div data-role="header" data-position="inline">

                          <h1>Transfer Files</h1>

                          <script type="text/javascript">

                       

                                  function setTransferResult(transResult)

                                  {

                                      document.getElementById("transferResult").innerHTML = transResult;

                                  }

                           </script>

                        </div> 

                       

                        <div data-role="content">

                            <div id="transferResult" style="font-size:1.2em;text-align:center">RESULT

                            </div>

                       

                            <div id="uploadFile">

                              <a href="/app/TransferFiles/uploadFileViaFTPWithCredentials" data-role="button" data-ajax="false" id="uploadFileBtn">Upload File</a>

                            </div>

                       

                            <div id="downloadFile">

                              <a href="/app/TransferFiles/downloadFileWithCredentials" data-role="button" data-ajax="false" id="downloadFileBtn">Download File</a>

                            </div>

                           

                        </div>

                       

                      </div>

                       

                       

                       

                      ...I haven't fixed the unitialised constant error yet.  Next on my list of many things to do   Any ideas welcome.

                        • Re: FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer
                          Mark Nongkhlaw

                          Just a quick glance at your code tells me you've followed the examples given in the docs anyway.

                           

                          But this error means there's some problem somewhere in line 16 of your controller under method uploadFileViaFTPWithCredentials :

                           

                          /Users/david/Development/StockTake/app/TransferFiles/transfer_files_controller.rb:16:in `uploadFileViaFTPWithCredentials'

                           

                          Maybe you can re-check that.

                           

                          Not sure what Rho version you're using, but you might want to see this somewhat related post (of course its concerning downloads, not uploads, but could be useful) :

                           

                          https://developer.motorolasolutions.com/message/10601#10601

                           

                          P.S. I notice this line in your code :

                           

                          FileTransfer.source="url('file://Users/david/Documents/myfile.txt')"

                           

                          In the docs its mentioned that its for http downloads, not uploads.

                           


                           

                          Message was edited by: Mark Nongkhlaw

                            • Re: FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer
                              David Miller

                              Ok.  Back to it.  Where was I?

                               

                              /Users/david/Development/StockTake/app/TransferFiles/transfer_files_controller.rb:16:in `uploadFileViaFTPWithCredentials'

                              I can't see anything wrong with that line...

                              FileTransfer.transferEvent=url_for(:action => :transferEventListener)

                               

                              I am focussing on the FileTransfer Module/library is not being loaded.  For some reason.  I can't see that it needs a 'require'.

                               


                              As for the ...

                              FileTransfer.source="url('file://Users/david/Documents/myfile.txt')"

                              ...line, I assume that the 'upload' function needs a source and the example is simply wrong.  Otherwise how else is it going to work without knowing which is the source file?

                               



                                • Re: Re: FileTransfer on WM6.5 - Error : can not find autocomplete/FileTransfer
                                  Pietro Francesco Maggi

                                  I've changed a bit the require of your controller to:

                                   

                                  require 'rho'
                                  require 'rho/rhocontroller'
                                  require 'rho/rhoerror'
                                  require 'helpers/browser_helper'
                                  

                                   

                                  One thing to keep in mind is that the "FileTransfer Module" is only supported on Windows Embedded Handheld and Android: you cannot test this APi inside RhoSimulator.

                                   

                                  On top of that, be sure to have in your build.yml the "Motorola_browser" capability enabled and the "non_motorola_device" capability disabled.

                                   

                                  Let me know if this solves your issue.

                                   

                                  ~Pietro