Results 1 to 9 of 9

Thread: Copying files to network drives

  1. #1
    Senior Member
    Join Date
    Jan 2014
    Posts
    262

    Copying files to network drives

    Hi guys

    We are trying to copy a file from our app to a network folder.

    It works fine in dev but doesn't in web.

    We understand that browsers are sandboxed but this is a server side procedure so we assume it should.

    We are trying to do :

    lsourcefile = "C:\Lianja\cloudserver\tenants\public\wwwroot\abct est.txt"
    ldestination = "W:\Testfolder\abctest.txt"

    copy file (lsourcefile) to (ldestination)

    Web page inspector doesn't like this - it throws all sorts of Lianja issues.


    Is there something we have missed?

    Thanks in advance


    Simon
    Last edited by SpringBox; 2019-11-06 at 13:43.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    Hi Simon

    Assuming that is in a server side proc that you are calling from the client using Lianja.evaluate() then there will be no errors on the client from calling this.

    You need to verify that the permissions for w: allow you to copy files to it from the cloud server.

    You can test this interactively in the browser from the JavaScript console.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Senior Member
    Join Date
    Jan 2014
    Posts
    262
    Thanks Barry

    Had a look at this,even changed backslashes for forward slashes, just in case but always the same.

    Works fine in Dev.

    Attached is some of the browser red stuff !!

    Name:  Lianja01.jpg
Views: 45
Size:  218.8 KB

    We are not really sure what this means

    Yes it is a serverside VFP procedure and the source file exists.

    Any ideas?

    Cheers

    Simon
    Last edited by SpringBox; 2019-11-06 at 15:13.

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,941
    Hi Simon,

    I like to have server side actions on the network test for all possible network issues. .

    In this case, I would have the prg first check for the folder where the file is being copied. E.g.,

    Code:
    // movefile.prg 
    lparameters tcPathedFromFile, tcPathedToFile
    
    // Here I would check that the From file exists
    
    lcPathedFolder = justpath(tcFile)
    llDirOK = directory(lcPathedFolder)
    if !llDirOK
       ? "Houston, we have a problem"
       return "Folder Not Reachable"
    endif
    
    /* Note: here I put in tests for copying a test file with nothing in it and a .txt suffix to the pathed folder and then being able to see it there.
    That way I know I can check whether the copying worked,
    That testing also will show up anti-virus file extension permissions issues. */
    
    copy file (tcPathedFromFile) to (tcPathedToFile)
    
    // check that the file move worked
    
    return "true"
    It's a PITA to have to get on a customer's network to find out my files aren't moving -- and then find out they decided, e.g., that the right permissions aren't there. I write these routines up as library routines: write once, use many. I log all errors to an error database, and access the database from a web app. Saving Support time, whether it mine or a support colleague, is aggravation and money saved.

    enjoy,

    Hank
    Last edited by HankFay; 2019-11-06 at 18:57.

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    You don’t need to change backslashes you are running on windows.

    Looks like your server proc is failing with an error and you are not handling it in a try / catch which you can do in JavaScript on the client and in your server code.

    As a mentioned earlier. You can test this in the console.

    When running in dev mode you are most likely running as an administrator.

    Running in the web, your code is running under the cloud server which is a service not running as administrator. So you need to open up permissions on your w: drive.

    Another thing to bear in mind. This is running as a multi user application so many users can be running your code at the same time. Using a copy of a known filename is not going to work, You need to use unique filenames. That’s a design flaw in what you are doing.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Senior Member
    Join Date
    Jan 2014
    Posts
    262
    Thanks for the replies guys


    Hank - yes testing everything is there before a copy makes good sense.

    Barry - Agreed about filenames - we are using filenames based on :

    lfilename = substr(juststem(SYS(2015)),2,12) + '.csv' which seems to provide uniqueness.

    We always test in the console when we are trying to get things to work as a scratch pad but earlier you said "You can test this interactively in the browser from the JavaScript console" which we don't understand. Could you please clarify.

    Going to put this in a TRY/CATCH for safety's sake. It sounds like a permissions issue.

    Thanks guys

    Simon

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    Hi Simon,

    To test in the browser javascript console see below. I'm using chrome so if you a different browser tell me which and i'll show you.

    For chrome.

    Name:  Screen Shot 2019-11-07 at 11.16.29 AM.jpg
Views: 47
Size:  96.7 KB
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #8
    Senior Member
    Join Date
    Feb 2012
    Location
    Rome - Italy
    Posts
    1,881
    Hi,
    the server have the network drive mapped as "W:"? the same of the client?

    ciao
    Fabio

  9. #9
    Senior Member
    Join Date
    Jan 2014
    Posts
    262
    Aha !!

    Never knew you could do that !!

    Already proved useful

    Thanks

    Simon

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us