Announcement

Collapse
No announcement yet.

URLDownloadToFile

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

    URLDownloadToFile

    For solutions to downloading files, I've used TCP statements so I could monitor download progress and I've used URLDownloadTo File for simpler code.

    I've yet to have a problem with URLDownloadToFile, other than needing to clear the cache, and wondered if anyone knows a reason why it's not a completely acceptable approach for downloading files?

    #2
    .. if anyone knows a reason why [URLDownLoadtoFile is] not a completely acceptable approach for downloading files?
    Not acceptable to whom?

    (BTW: you don't need to clear the cache, unless you are trying to do some kind of quasi-realtime monitoring, in which case URLDownloadToFile is, IMO, a really inferior design)


    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


      #3
      > For solutions to downloading files, I've used TCP statements so I could monitor download progress and I've used URLDownloadTo File for simpler code.

      You can also monitor download progress with UrlDownloadToFile.
      Last edited by José Roca; 21 May 2018, 02:01 PM. Reason: Typo correction
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


        #4
        Hi MCM,
        To me, of course!

        But, more seriously, my question is whether there any serious technical problems known to exist with the API, work arounds needed to get useful/repeatable results, applications in which the API is known to give problems, ... that kind of stuff. If someone has made a choice NOT to use the API, I'm interested in hearing why.

        Comment


          #5
          Hey Jose!

          Thanks for the input, but neither I, nor Google, seem to have heard of that API...

          Showing results for UrlDownloadToFile
          No results found for UstlDownloadToFile
          Can you guide me to some information on the API?

          Comment


            #6
            Old fashion, but the idea is there... URLDownloadToFile

            Comment


              #7
              Originally posted by Gary Beene View Post
              Hey Jose!

              Thanks for the input, but neither I, nor Google, seem to have heard of that API... ?



              Can you guide me to some information on the API?
              Sorry, it was a typo. I mean UrlDownloadToFile,

              BTW we already have discussed it. See: https://forum.powerbasic.com/forum/u...dtofile-vs-tcp

              Also see my WinHttpRequest examples, e.g.




              Forum: http://www.jose.it-berater.org/smfforum/index.php

              Comment


                #8
                (BTW: you don't need to clear the cache, unless you are trying to do some kind of quasi-realtime monitoring, in which case URLDownloadToFile is, IMO, a really inferior design)
                MCM
                MCM.
                Why are you telling people not to clear the cache before downloading?
                If a file exists in cache the download will continue to use the old copy in cache.

                hr =DeleteURLCacheEntry(sURL + $NUL) '1 = success clear the cache before download

                GB,
                I've yet to have a problem with URLDownloadToFile, other than needing to clear the cache, and wondered if anyone knows a reason why it's not a completely acceptable approach for downloading files?
                1. It doesn't work with https. wrong, it is working now. had trouble with it years ago. thanks bob carver.
                2. Not a secure channel
                3. Data can be intercepted and read or changed
                4. Data is not verified.
                5. Data may not be encrypted

                I've posted code using Jose's code with progress.
                There is also code somewhere to download https using TCP, but can't find it.
                Still doubt if it is using a secure channel.
                Last edited by Mike Doty; 21 May 2018, 04:50 PM.

                Comment


                  #9
                  Why are you telling people not to clear the cache before downloading?
                  I did not say not to do it; I said it was unnecessary UNLESS <application condition>.

                  What you have described is multiple downloads of the same filename, which pretty much equals <application condition>.

                  But going back to my first point: I did NOT suggest not clearing the cache. Please do not misquote me like this.

                  MCM
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                    #10
                    you don't need to clear the cache, unless you are trying to do some kind of quasi-realtime monitoring,
                    This is inaccurate

                    Comment


                      #11
                      Originally posted by Mike Doty View Post
                      1. It doesn't work with https
                      This is also inaccurate

                      Comment


                        #12
                        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

                        Comment


                          #13
                          Hey Mike,
                          Aren't your 2-5 comments a function of whether the site has an SSL certificate? If it does, then the 2-5 issues you discuss do not apply, do they?

                          MCM,
                          Thanks for this opinion...
                          ....a really inferior design)
                          .... but could you clarify why you have the opinion?

                          Comment


                            #14
                            Depends if connection is secure.
                            A browser will use TLS, but does urlDownloadToFile make a secure connection?

                            Comment


                              #15
                              Mike,
                              That's a good question. I'll contact my server folks and see what they know about it.

                              Comment


                                #16
                                When I look at 3rd party controls they always seem to have a parameter like bUseTls

                                Comment


                                  #17
                                  In post#8, I said urlDownloadToFile stopped working when using https.
                                  That should have been tcp stopped working with https: Thanks to Bob Carver for reporting my error.
                                  Somebody posted code to work with TCP (which I need to find), but I switched to Jose Roca code a couple of years ago with progress bar.

                                  Gary,
                                  About urlDownloadToFile automatically making a secure connection (which I doubt.)
                                  Mike,
                                  That's a good question. I'll contact my server folks and see what they know about it.

                                  Comment


                                    #18
                                    HTTPS uses TCP

                                    HTTP uses TCP

                                    FTP uses TCP

                                    Lots of protocols use TCP. Your problem is not with TCP, it is the security that HTTPS adds that HTTP does not use.

                                    TCP and UDP are different things at the same level, and they use IP.

                                    IP uses ethernet.

                                    Ethernet can use CAT-5, coax, optical fiber, WiFi, etc, etc.

                                    What you are looking for is the security code (as in PB source code).

                                    TCP never stopped working with HTTPS, and is still needed, you just don't have enough code.

                                    added: If you use API or 3rd party DLL for HTTPS you may not see code for TCP OPEN, TCP SEND, etc, but the TCP is there. It is just that you don't use PB's TCP statements. If you find just security code then you do use PB's TCP statements.
                                    Dale

                                    Comment


                                      #19
                                      Does urlDownloadToFile offer any certificate security?

                                      https://forum.powerbasic.com/forum/u...-ssl-supported

                                      .
                                      If anyone has security code for secure TLS connections, please post a link.
                                      Here is some c++ code using schannel
                                      client/server with links in the source code.
                                      https://www.codeproject.com/Articles...erver-With-SSL

                                      urlDownloadToFile is definitely fast as Patrice says below.

                                      Comment


                                        #20
                                        URLDownloadToFile is very reliable and fast, i am using it in several of my 64-bit applications.

                                        This is what i am using to retrieve in real time movie informations from TMDB, to display this




                                        SDK example to get a movie poster

                                        Code:
                                        [FONT=Consolas][SIZE=10px][COLOR=#008000][FONT=Consolas][SIZE=10px][COLOR=#008000][FONT=Consolas][SIZE=10px][COLOR=#008000]// Get poster[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF]long[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px] TMD_GetPoster([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A]IN[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#2B91AF][FONT=Consolas][SIZE=10px][COLOR=#2B91AF][FONT=Consolas][SIZE=10px][COLOR=#2B91AF]WCHAR[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]* [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#808080][FONT=Consolas][SIZE=10px][COLOR=#808080][FONT=Consolas][SIZE=10px][COLOR=#808080]UsePath[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]) {[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF]long[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px] nRet = 0;[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][COLOR=#2B91AF][FONT=Consolas][SIZE=10px][COLOR=#2B91AF][FONT=Consolas][SIZE=10px][COLOR=#2B91AF]WCHAR[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px] zURL[[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A]MAX_PATH[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]]; ClearMemory(zURL, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF]sizeof[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px](zURL));[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]Path_Combine(zURL, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#A31515][FONT=Consolas][SIZE=10px][COLOR=#A31515][FONT=Consolas][SIZE=10px][COLOR=#A31515]L"https://image.tmdb.org/t/p/w500/"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px], gM.poster_path);[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]Path_Combine(gTMD.poster, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#808080][FONT=Consolas][SIZE=10px][COLOR=#808080][FONT=Consolas][SIZE=10px][COLOR=#808080]UsePath[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px], [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#A31515][FONT=Consolas][SIZE=10px][COLOR=#A31515][FONT=Consolas][SIZE=10px][COLOR=#A31515]L"TMD_poster.jpg"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]);[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A]URLDownloadToFile[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A]NULL[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px], zURL, gTMD.poster, 0, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A]NULL[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]) == [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A][FONT=Consolas][SIZE=10px][COLOR=#6F008A]S_OK[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]) {[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]   nRet = -1;[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]} [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF]else[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px] {[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]   ClearMemory(gTMD.poster, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF]sizeof[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px](gTMD.poster));[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]}[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF][FONT=Consolas][SIZE=10px][COLOR=#0000FF]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px] nRet;[/SIZE][/FONT][/SIZE][/FONT]
                                        [FONT=Consolas][SIZE=10px][FONT=Consolas][SIZE=10px]}[/SIZE][/FONT][/SIZE][/FONT]
                                        Patrice Terrier
                                        www.zapsolution.com
                                        www.objreader.com
                                        Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                                        Comment

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