a97 - problem transfer file from server with https

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hanspeter Leupin

    #1

    a97 - problem transfer file from server with https

    Hi NG,

    I used the Internet Data Transfer Library of Dev Ashish found at
    http://www.mvps.org/access/modules/mdl0037.htm to transfer text files from
    a server with HTTPS in my old Ms Access 97 application.

    '----snip----
    Sub TestHTTP()
    On Error GoTo ErrHandler
    Dim objHTTP As InetTransferLib .HTTP
    Const conTARGET = "https://ip.of.my.server/PathToMyFile/MyFile.csv"

    Set objHTTP = New InetTransferLib .HTTP
    With objHTTP
    .HttpURL = conTARGET
    .DestinationFil e = "c:\MyFile. csv"
    If .FileExists Then .OverwriteTarge t = True
    .ConnectToHTTPH ost
    .WriteHTTPDataT oFile
    End With
    ExitHere:
    On Error Resume Next
    Set objHTTP = Nothing
    Call SysCmd(acSysCmd RemoveMeter)
    Exit Sub
    ErrHandler:
    MsgBox Err.Number & vbCrLf & Err.Description , vbCritical + vbOKOnly,
    Err.Source
    Resume ExitHere
    End Sub

    This code was running fine for months - I did not changed anything but for
    a couple of days I receive an error 6 - overflow message when
    ..WriteHTTPData ToFile is in progress.

    The file size of MyFile.csv is about 100-250kb...

    I tried to use the microsoft internet transfer control activex v6.0 but
    with no success... ;-(

    Any help or sample code is welcome

    Regards

    Hanspeter
  • Terry Kreft

    #2
    Re: a97 - problem transfer file from server with https

    IIRC there is a bug in the INetTransferLib .

    In the WriteHTTPDataTo File and the WriteFTPDataToF ile ther is a line which
    looks like this
    Call apiWriteFile(hF ile, abytData(0), MAX_CHUNK, _
    lngBytesWritten , 0&)


    Which should be this
    Call apiWriteFile(hF ile, abytData(0), lngBytesRead, _
    lngBytesWritten , 0&)




    --
    Terry Kreft



    "Hanspeter Leupin" <leh00@csi.co m> wrote in message
    news:1lq4eme86x q5s$.9hxsff8ngj u0.dlg@40tude.n et...[color=blue]
    > Hi NG,
    >
    > I used the Internet Data Transfer Library of Dev Ashish found at
    > http://www.mvps.org/access/modules/mdl0037.htm to transfer text files from
    > a server with HTTPS in my old Ms Access 97 application.
    >
    > '----snip----
    > Sub TestHTTP()
    > On Error GoTo ErrHandler
    > Dim objHTTP As InetTransferLib .HTTP
    > Const conTARGET = "https://ip.of.my.server/PathToMyFile/MyFile.csv"
    >
    > Set objHTTP = New InetTransferLib .HTTP
    > With objHTTP
    > .HttpURL = conTARGET
    > .DestinationFil e = "c:\MyFile. csv"
    > If .FileExists Then .OverwriteTarge t = True
    > .ConnectToHTTPH ost
    > .WriteHTTPDataT oFile
    > End With
    > ExitHere:
    > On Error Resume Next
    > Set objHTTP = Nothing
    > Call SysCmd(acSysCmd RemoveMeter)
    > Exit Sub
    > ErrHandler:
    > MsgBox Err.Number & vbCrLf & Err.Description , vbCritical + vbOKOnly,
    > Err.Source
    > Resume ExitHere
    > End Sub
    >
    > This code was running fine for months - I did not changed anything but for
    > a couple of days I receive an error 6 - overflow message when
    > .WriteHTTPDataT oFile is in progress.
    >
    > The file size of MyFile.csv is about 100-250kb...
    >
    > I tried to use the microsoft internet transfer control activex v6.0 but
    > with no success... ;-(
    >
    > Any help or sample code is welcome
    >
    > Regards
    >
    > Hanspeter[/color]


    Comment

    • Red

      #3
      Re: a97 - problem transfer file from server with https

      I love Dev's coding...

      But, I would guess that the file being written is to big... but,
      honestly, this is just a guess


      ~Red

      Comment

      • Hanspeter Leupin

        #4
        Re: a97 - problem transfer file from server with https

        Hi Terry,

        Thanks for your replay.

        On Fri, 6 Jan 2006 16:29:36 -0000, Terry Kreft wrote:
        [color=blue]
        > Call apiWriteFile(hF ile, abytData(0), MAX_CHUNK, _
        > lngBytesWritten , 0&)
        > Which should be this
        > Call apiWriteFile(hF ile, abytData(0), lngBytesRead, _
        > lngBytesWritten , 0&)[/color]


        I replaced MAX_CHUNK with lngBytesRead... well the overflow error is gone -
        but the download of the file doesn't work. The code loops for ever at the
        line where I did the change. The progress bar doesn't move and the filesize
        of my 20kb file stays at 0...

        lngTotalBytesWr itten = 0
        'Read in MAX_CHUNK Chunk
        Do
        ReDim abytData(MAX_CH UNK)
        lngRet = apiInetReadFile (hURL, abytData(0), MAX_CHUNK, lngBytesRead)
        Call apiWriteFile(hF ile, abytData(0), lngBytesRead, _
        lngBytesWritten , 0&)
        lngTotalBytesWr itten = lngTotalBytesWr itten + lngBytesWritten
        Call SysCmd(acSysCmd UpdateMeter, CInt(lngTotalBy tesWritten / mlngSize))
        Loop Until lngRet <> 0 And lngBytesRead = 0


        Any ideas or is there something missing ?

        Hanspeter

        Comment

        • Hanspeter Leupin

          #5
          Re: a97 - problem transfer file from server with https

          On 6 Jan 2006 07:45:41 -0800, Red wrote:
          [color=blue]
          > I love Dev's coding...
          >
          > But, I would guess that the file being written is to big... but,
          > honestly, this is just a guess
          >
          >
          > ~Red[/color]

          Hi Red,

          well the code was fine till two weeks ago. The filesize was always in the
          same range...

          Is there no other code to transfer a file from https with a97?

          Regards

          Hanspeter

          Comment

          • Terry Kreft

            #6
            Re: a97 - problem transfer file from server with https

            OK, there's something else going on.

            Firstly don't worry about the file size staying at zero, IIRC the file size
            doesn't get written until the download is finished.

            I've tested this and it works fine.

            The relevant piece of code I have in WriteHTTPDataTo File is :-
            lngTotalBytesWr itten = 0
            'Read in MAX_CHUNK Chunk
            Do
            ReDim abytData(MAX_CH UNK)
            lngRet = apiInetReadFile (hURL, _
            abytData(0), _
            MAX_CHUNK, _
            lngBytesRead)
            Call apiWriteFile(hF ile, abytData(0), lngBytesRead, _
            lngBytesWritten , 0&)
            lngTotalBytesWr itten = lngTotalBytesWr itten + lngBytesWritten
            Call SysCmd(acSysCmd UpdateMeter, CInt(lngTotalBy tesWritten / mlngSize))
            Loop Until lngRet <> 0 And lngBytesRead = 0


            I'm call ing the routine as follows
            Sub TestHTTP()
            On Error GoTo ErrHandler
            Dim objHTTP As InetTransferLib .HTTP
            Const conTARGET = "http://www.mvps.org/access/acknowledge.htm "

            Set objHTTP = New InetTransferLib .HTTP
            With objHTTP
            .HttpURL = conTARGET
            .DestinationFil e = "C:\test.ht m"
            If .FileExists Then .OverwriteTarge t = True
            .ConnectToHTTPH ost
            .WriteHTTPDataT oFile
            End With
            ExitHere:
            On Error Resume Next
            Set objHTTP = Nothing
            Call SysCmd(acSysCmd RemoveMeter)
            Exit Sub
            ErrHandler:
            MsgBox Err.Number & vbCrLf & Err.Description , vbCritical + vbOKOnly,
            Err.Source
            Resume ExitHere
            End Sub

            and this works. (the file created is 73.5 kb).

            In the WriteHTTPDataTo File procedure try keeping a track of
            lngBytesRead this should be at most MAX_CHUNK
            lngBytesWritten this should be at most lngBytesRead
            lngTotalBytesWr itten this should be at most the size of your file in
            bytes.

            --
            Terry Kreft



            "Hanspeter Leupin" <leh00@csi.co m> wrote in message
            news:rwvy26nnn7 5k$.k0kwl0d4jvo 0.dlg@40tude.ne t...[color=blue]
            > Hi Terry,
            >
            > Thanks for your replay.
            >
            > On Fri, 6 Jan 2006 16:29:36 -0000, Terry Kreft wrote:
            >[color=green]
            >> Call apiWriteFile(hF ile, abytData(0), MAX_CHUNK, _
            >> lngBytesWritten , 0&)
            >> Which should be this
            >> Call apiWriteFile(hF ile, abytData(0), lngBytesRead, _
            >> lngBytesWritten , 0&)[/color]
            >
            >
            > I replaced MAX_CHUNK with lngBytesRead... well the overflow error is
            > gone -
            > but the download of the file doesn't work. The code loops for ever at the
            > line where I did the change. The progress bar doesn't move and the
            > filesize
            > of my 20kb file stays at 0...
            >
            > lngTotalBytesWr itten = 0
            > 'Read in MAX_CHUNK Chunk
            > Do
            > ReDim abytData(MAX_CH UNK)
            > lngRet = apiInetReadFile (hURL, abytData(0), MAX_CHUNK, lngBytesRead)
            > Call apiWriteFile(hF ile, abytData(0), lngBytesRead, _
            > lngBytesWritten , 0&)
            > lngTotalBytesWr itten = lngTotalBytesWr itten + lngBytesWritten
            > Call SysCmd(acSysCmd UpdateMeter, CInt(lngTotalBy tesWritten / mlngSize))
            > Loop Until lngRet <> 0 And lngBytesRead = 0
            >
            >
            > Any ideas or is there something missing ?
            >
            > Hanspeter[/color]


            Comment

            • Hanspeter Leupin

              #7
              Re: a97 - problem transfer file from server with https

              On Sat, 7 Jan 2006 12:17:29 -0000, Terry Kreft wrote:
              [color=blue]
              > OK, there's something else going on.
              >
              > Firstly don't worry about the file size staying at zero, IIRC the file size
              > doesn't get written until the download is finished.
              >
              > I've tested this and it works fine.
              >
              > Const conTARGET = "http://www.mvps.org/access/acknowledge.htm "
              >
              > and this works. (the file created is 73.5 kb).
              >[/color]

              Hi Terry,

              I checked all the code and I tried the sample you did and it works fine
              too! The download of http://www.mvps.org/access/acknowledge.htm worked...
              but when I go back to my https page on the intranet the download breaks and
              loops for ever... I reinstalled the certificates...

              When ever IE was in the background open to the secure page - access97
              successfully downloaded the files...

              Well - we can keep on right click the files and store them localy... :-)

              Reagrds

              Hanspeter

              Comment

              Working...