Download binary data from WebService

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nikolay Petrov

    #1

    Download binary data from WebService

    Any general ideas how to get binary data(files) from WebService to an
    ASP .NET app and then save it to client's machine?

    Thanks

  • Cor Ligthert

    #2
    Re: Download binary data from WebService

    Nikolay,

    You have first to serialize them.

    A sample from Tom that I find nice

    \\\Tom Shelton
    Private Function SerializeFontOb ject(ByVal fnt As Font) As String
    Dim bf As New BinaryFormatter
    Dim mem As New MemoryStream
    Try
    bf.Serialize(me m, fnt)
    Return Convert.ToBase6 4String(mem.ToA rray())
    Catch
    Return String.Empty
    Finally
    mem.Close()
    End Try
    End Function
    Private Function DeserializeFont Object(ByVal fnt As String) As Font
    Dim bf As New BinaryFormatter
    Dim mem As New MemoryStream(Co nvert.FromBase6 4String(fnt))
    Try
    Return DirectCast(bf.D eserialize(mem) , Font)
    Finally
    If Not mem Is Nothing Then
    mem.Close()
    End If
    End Try
    End Function

    I hope this helps a little bit?

    Cor


    Comment

    • Nikolay Petrov

      #3
      Re: Download binary data from WebService

      I know I can also use DIME attachments, so I don't need to convert the
      data to Base64.

      my question was not very exact .

      I am looking in to way of sending big files (over 10MB). The way of
      using DIME attachements is good for this, because i can split the files
      to parts, not send them as one piece. I've used the for upload and it
      works great.

      The problem is that I can't figure out how to ask the web service for
      the first part, then second and so on.

      when uploading to web service i do a FOR loop and send chunks if data
      to service, which concantenates them in file, but how to make the
      service reads parts of the file and send them is unclear to me.

      the reason i want to split the transfered files to parts is that it
      will consume a lot of memory at the server if I read the whole file,
      serialize it and then start sending it.

      Comment

      • Cor Ligthert

        #4
        Re: Download binary data from WebService

        Nikolay,

        I thought I answered this question already like this, however when not.

        Why don't you just download them with webclient downloadfile, where you get
        the url from the webservice

        I hope this helps?

        Cor


        Comment

        • Nikolay Petrov

          #5
          Re: Download binary data from WebService

          this will also work i guess


          tnx.

          Comment

          Working...