Connecting to a remote file on my site

  1. 5 days ago

    Paulo V

    Nov 8 Porto Alegre, Brasil

    Hello,

    I have a question that may sound pretty basic but since I've never done anything like this I don't know where to start let me explain.

    I need an App (Mac) that I'm developing for a specific client to do when opening a check if a file exists (.txt) in a folder on their site and if it doesn't exist returns with a message.

    It would go to www.sitexxx.com/ files/ ACT.txt and if the file does not exist the program returns an error message in a Msgbox.

  2. Julian S

    Nov 8 Pre-Release Testers, Xojo Pro UK

    What version of xojo are you using?

  3. Paulo V

    Nov 8 Porto Alegre, Brasil

    Xojo 2017 Release 2.1

  4. Julian S

    Nov 8 Pre-Release Testers, Xojo Pro UK

    Sorry for delay, had to afk. Have a look in Example Projects>Communication>Internet>HTTPDownloader

    In the Download method, think about changing the Downloader.Get to

    Downloader.Get(URL As String, Timeout As Integer) As String

    Check the in built Language Reference for more info.

    Let us know if you get stuck :)

  5. Paulo V

    Nov 8 Porto Alegre, Brasil

    @Julian S Sorry for delay, had to afk. Have a look in Example Projects>Communication>Internet>HTTPDownloader

    In the Download method, think about changing the Downloader.Get to

    Downloader.Get(URL As String, Timeout As Integer) As String

    Check the in built Language Reference for more info.

    Let us know if you get stuck :)

    Thanks for the help I'll have a look in this.

  6. Paulo V

    Nov 8 Porto Alegre, Brasil
    Edited 5 days ago

    I think this is not yet what I need, I need to check if the file is there to continue or get a warning Not Found for APP not to continue.

    Any ideas are welcome !

  7. Julian S

    Nov 8 Pre-Release Testers, Xojo Pro UK

    Here you go Paulo, it might need some tweaking depending on the server set up/language etc.

    https://www.dropbox.com/s/7m0z7fmcex5f8mh/DoesPageExistPaulo.xojo_binary_project?dl=0

  8. Jean-Yves P

    Nov 8 Pre-Release Testers, Xojo Pro Europe (France, Besançon)
    Edited 5 days ago
    HTTPSecureSocket.Get(URL As String, Timeout As Integer) As String

    should be what you need ?

  9. Paulo V

    Nov 8 Porto Alegre, Brasil
    Edited 5 days ago

    @Julian S Here you go Paulo, it might need some tweaking depending on the server set up/language etc.

    https://www.dropbox.com/s/7m0z7fmcex5f8mh/DoesPageExistPaulo.xojo_binary_project?dl=0

    Again thanks so much Julian Samphire and Jean-Yves Pochez for the help you are giving me !

    Julian I don't know what may be happening, but when I change the project path to my site (or any other fiction) and do the test it always returns True.

    To be clear, I just opened the project that kindly sent me and changed the address (Path) and return true every time, I don't know what could be going wrong, any idea why this is happening?

  10. Julian S

    Nov 8 Pre-Release Testers, Xojo Pro UK

    If your server doesn't include the string "404 - File Or directory Not found." in the source when the file is not found then it won't match correctly, you'll need to tweak that as I mentioned above. If your server does any redirection or uses https then the code will also need to be tweaked. PM me the full URL if you want and I'll take a quick look.

  11. Paulo V

    Nov 8 Porto Alegre, Brasil
    Edited 5 days ago

    Yeah, there are all these variables that can make it difficult if I need to target more than 1 server or even replace it, I think I'll have to think better about it because I imagined a simple system to recognize whether a page exist and return me a true or false but I will have to think better.

    Maybe I'll even have to study a bit of how access via database this, anyway thanks for the immense help you gave me!

  12. Jeff T

    Nov 8 Pre-Release Testers Midlands of England, Europe

    I use this, but it relies on knowing what the file content should be, rather than whether a page 'exists at all'
    On my site I have an XML file sitting
    This checks whether it exists and is XML

     dim h as new HTTPSocket
      h.yield = true
      dim x as string
      x= h.get ("http://www,mysite.com/afolder/thefile.xml",2)
      
     
      if h.HTTPStatusCode = 200  then  // got an OK response.. now is it our file or a redirect?
        if  left(x,5) = "<?xml" then
         
    msgbox "File  exists"
        end if
      end if
  13. Paulo V

    Nov 8 Porto Alegre, Brasil

    @Jeff T I use this, but it relies on knowing what the file content should be, rather than whether a page 'exists at all'
    On my site I have an XML file sitting
    This checks whether it exists and is XML

    dim h as new HTTPSocket h.yield = true dim x as string x= h.get ("http://www,mysite.com/afolder/thefile.xml",2) if h.HTTPStatusCode = 200 then // got an OK response.. now is it our file or a redirect? if left(x,5) = "<?xml" then msgbox "File exists" end if end if

    Oh, I like your approach, I'll test it and tell you again if it works for what I need.

    Thanks in advance for the help, Jeff Tullin !

or Sign Up to reply!