Announcement

Collapse
No announcement yet.

URLDownloadToFile

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stuart McLachlan
    replied
    Originally posted by Mark Hunter View Post

    If your client runs any executable of yours they have given you the keys to the kingdom. You can use URLDownloadToFile to ... [deleted, I went into detail but it's best this idea was not too publicly available].
    Initially very cunfusing
    In the context of web services, "client" usually means the machine or application requesting something from a server, not someone you are doing development for

    Leave a comment:


  • Mark Hunter
    replied
    Originally posted by Mike Doty View Post
    Does urlDownloadToFile offer any certificate security?
    If your client runs any executable of yours they have given you the keys to the kingdom. You can use URLDownloadToFile to ... [deleted, I went into detail but it's best this idea was not too publicly available].
    Last edited by Mark Hunter; 17 May 2023, 11:43 PM.

    Leave a comment:


  • Steve Bouffe
    replied
    Seems that internet explorer enhance security function was enabled.

    Setting changed, log off and on again.

    All is well!

    Leave a comment:


  • Mike Doty
    replied
    Code:
    #INCLUDE  "\roca\MSXML.INC" 'use Roca includes
    
    FUNCTION PBMAIN()
      LOCAL ws AS WSTRING
      ws = test("https://www.djsuperstore.com/robots.txt")
      ? ws
    END FUNCTION
    
    
    FUNCTION test(wsUrl AS WSTRING) AS WSTRING
      DIM sMethod AS WSTRING
      DIM oXml AS IServerXMLHTTPRequest2
      SET oXml = NEWCOM "MsXml2.ServerXMLHTTP.6.0"
      sMethod = "GET"
      IF ISTRUE(ISOBJECT(oXml)) THEN
          oXml.Open(sMethod, wsURL, %FALSE)
          oXml.Send()
          DO WHILE oXml.ReadyState<>4
              SLEEP 0
              ? "[" & STR$(oXml.ReadyState) & "]"
              ? "error exit function":EXIT FUNCTION
          LOOP
          FUNCTION= oXml.ResponseText
      ELSE
          ? "Unable to get version",,FUNCNAME$
      END IF
    END FUNCTION


    Leave a comment:


  • Mike Doty
    replied
    See post #22 (which is different.)

    Leave a comment:


  • Steve Bouffe
    replied
    Mike,

    Do you have a compilable example?

    Leave a comment:


  • Mike Doty
    replied
    > The download of the specified resource has failed.

    > Does urlDownloadToFile use Internet explorer components?
    Do not know.

    Does this work?
    Syntax: wsFile = test("https://www.yoursite.com/yourfile.txt")

    Code:
    FUNCTION test(wsUrl AS WSTRING) AS WSTRING
      DIM sMethod AS WSTRING
      DIM oXml AS IServerXMLHTTPRequest2
      SET oXml = NEWCOM "MsXml2.ServerXMLHTTP.6.0"
      sMethod = "GET"
      IF ISTRUE(ISOBJECT(oXml)) THEN
          oXml.Open(sMethod, wsURL, %FALSE)
          oXml.Send()
          DO WHILE oXml.ReadyState<>4
              SLEEP 0
              ? "[" & STR$(oXml.ReadyState) & "]"
              ? "error exit function":EXIT FUNCTION
          LOOP
          FUNCTION= oXml.ResponseText
      ELSE
          ? "Unable to get version",,FUNCNAME$
      END IF
    END FUNCTION

    Leave a comment:


  • Steve Bouffe
    replied
    Hello.

    hanks for all of your replies.

    I ran the program in #31 on my workstation and the directory was created and file downloaded.

    When I ran on the server the directory was created but still error -2146697208

    Does urlDownloadToFile use Internet explorer components?

    Click image for larger version

Name:	screen_shot.jpg
Views:	167
Size:	86.0 KB
ID:	822992
    The left dialog is the server that's failing and the right it's working ok. No matter what I try I'm unable to change the levels for the zone. I also tried adding to trusted sites and still failing.

    Leave a comment:


  • Pierre Bellisle
    replied
    > it's a very generic error whichh can have several causes.. It can mean that the file didn't exist or that the file couldn't be written or that there was a connectivity problem or ....

    If I may, do you have any Microsoft URL that confirm this.

    Context is urlDownloadToFile > error is urlmon.h - 0x800C0008L (-2146697208) INET_E_DOWNLOAD_FAILURE

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Pierre Bellisle View Post
    >Can mean - Unable to write file.

    Interesting...


    urlmon.h - 0x800C0008L (-2146697208) INET_E_DOWNLOAD_FAILURE
    Yes "can"

    it's a very generic error whichh can have several causes.. It can mean that the file didn't exist or that the file couldn't be written or that there was a connectivity problem or ....

    But given the issues identified in the OP's code and the fact that it is only happening on one machine, inability to write the file is a good first guess.

    Leave a comment:


  • Pierre Bellisle
    replied
    >Can mean - Unable to write file.

    Interesting...


    urlmon.h - 0x800C0008L (-2146697208) INET_E_DOWNLOAD_FAILURE

    Leave a comment:


  • Stuart McLachlan
    replied
    -2146697208 is 0x800c0008​
    Can mean - Unable to write file.

    > MKDIR C:\MyTest
    Do you have the rights to create a folder in the root of drive C:\ on the problem server?

    You create zlocalfile = "\mytest\junk.exe"
    Are you running the program from drive C: ?
    If you are running from from Drive E for example, you are creaing C:\MyTest but trying to write to E:\MyTest

    Also, try changing to WSTRINGZ rather than STRINGZ and checking the return from CacheEntryDelete:

    '
    Code:
    %UNICODE = 1
    #INCLUDE "win32api.inc"
    #INCLUDE "wininet.inc"
    FUNCTION PBMAIN()
    LOCAL errcode AS LONG
    LOCAL zurl AS WSTRINGZ * 512
    LOCAL zlocalfile AS WSTRINGZ * 512
    zurl = "https://djsuperstore.com/robots.txt" '200,000,000 bytes
    MKDIR "c:\mytest"
    ERRCLEAR
    zlocalfile = "C:\mytest\junk.exe"
    errcode = DeleteURLCacheEntry(zurl) '1=success, 0=failed
    IF errcode = 0 THEN ? "Cache entry deleted" ELSE ? "Can't delete cache entry" + STR$(errcode)
    errcode = urlDownloadToFile(BYVAL 0,zurl,zlocalfile,0,0)
    IF errcode = 0 THEN ? "Download ok" ELSE ? "Download error" + STR$(errcode)
    END FUNCTION
    '



    Otherwise, check the firewall on the problem server.

    Leave a comment:


  • Steve Bouffe
    replied
    Originally posted by Mike Doty View Post
    The file did not exist. Try it now.
    It should not have worked.
    Ah sorry I changed the url to https://djsuperstore.com/robots.txt

    Bit balled why the primary domain controller goves the error and the secondry doesn't

    Leave a comment:


  • Mike Doty
    replied
    The file did not exist. Try it now.
    It should not have worked.

    Leave a comment:


  • Steve Bouffe
    replied
    Originally posted by Mike Doty View Post
    Bob,
    You are right. It is definitely working.with Windows 10.
    Not sure what was going wrong a couple of years ago.
    Updated my remarks in post #8.
    Thank you!
    Code:
    #INCLUDE "win32api.inc"
    #INCLUDE "wininet.inc"
    FUNCTION PBMAIN()
    LOCAL errcode AS LONG
    LOCAL zurl AS ASCIIZ * 512
    LOCAL zlocalfile AS ASCIIZ * 512
    zurl = "https://www.dotysoftware.com/junk.exe" '200,000,000 bytes
    mkdir "c:\mytest"
    errclear
    zlocalfile = "\mytest\junk.exe"
    errcode = DeleteURLCacheEntry(zurl) '1=success, 0=failed
    errcode = urlDownloadToFile(BYVAL 0,zurl,zlocalfile,0,0)
    IF errcode = 0 THEN ? "Download ok" ELSE ? "Download error" + STR$(errcode)
    END FUNCTION
    The above example works fine with Win10 & 11 but when I try to run under Server 2016 I get

    Download error-2146697208

    Any suggestions?

    Actually I've tried this on another installation of Server 2016 and no issues. Need to investigate a bit more.

    Leave a comment:


  • Mike Doty
    replied
    Great news. Thank you!

    Leave a comment:


  • Stuart McLachlan
    replied
    1. Packet sniffer - WIreshark
    2. All HTTPS traffic uses TLS
    3. No, to upload a file, a web site must be running something like PHP to process the upload.
    4.See 2. above.
    5. See 2 above

    Leave a comment:


  • Kerry Farmer
    replied
    Hi Guys

    Interesting discussion - but a bit beyond my expertise

    I would like to offer a service where I spell check websites - amongst other things.

    So I would like to say 'please download onto file X all the contents of website Y'

    Can some kind guru tell me how to do that so that I understand?

    If there are issues with a few websites - well too bad, let us not worry about that.

    Thanks in advance.

    Kerry

    Leave a comment:


  • Mike Doty
    replied
    Looks good, but I don't have FTP servers.
    Still need to know if urldownloadtofile and the code I posted would be encrypted using TLS.

    Leave a comment:


  • Michael Mattias
    replied
    ) Is there an UrlUploadtofile?
    The way I wrote this Source Code Forum demo it's pretty close. And anyway, What's in a name? That which we would call a rose by any other name would smell as sweet!

    WinInet FTP Upload (Overwrite or Append) Demo 3-10-08

    Leave a comment:

Working...
X
😀
🥰
🤢
😎
😡
👍
👎