Glengamoi · AspHeute (Artikel) · .NET Heute (RSS-Suche) · .NET Blogs · Glengamoi Suche (Installieren via Klick)

Glengamoi

Die Diskussionsforen der deutschen .NET Community
Willkommen bei Glengamoi. Anmeldung | Registrieren | Hilfe
in Suchen

Problem beim Download von binary Data aus DB

Letzter Beitrag 03-29-2007 19:36 von Christoph Wille. 1 Antworten.
Seite 1 von 1 (2 Treffer)
Beiträge sortieren: Zurück Weiter
  • 03-29-2007 12:38

    Problem beim Download von binary Data aus DB

    Hi,

     

    ich will/muss Nutzern in einer Oracle 10 DB gespeicherte PDF´s zum Download anbieten.

    Prinzipiell funktioniert das auch, aber die PDF´s lassen sich nicht öffen und sind fast dreimal so groß, wie das Original. Also kommt irgendwoher irgendwelcher Mist noch dazu. Ich weiß leider nicht woher.

     

    Hier das komplette Script:

    <% @ LANGUAGE="VBSCRIPT"%>
    <%
    Response.Buffer = True
    Response.Clear
    Response.Expires = 0

    Call WriteFileBinaryFromDB(Request.QueryString("id"))

    Public Sub WriteFileBinaryFromDB(ByRef FileID)
        Dim doc_type, rs_ole, conn2, aDatasource, GetBinarySQL

        Set conn2 = Server.CreateObject("ADODB.Connection")
        aDatasource = "Provider=OraOLEDB.Oracle;Data Source=abc;" & _
                      "User Id=xxx;Password=yyy;"
        conn2.Open aDatasource
           
        GetBinarySQL = "SELECT ole_class, object_data FROM lims_sys.attachment WHERE attachment_id = " & FileID
        Set rs_ole = Server.CreateObject("ADODB.Recordset")
        rs_ole.Open GetBinarySQL, conn2, 2, 2
       
        doc_type = rs_ole.Fields("ole_class")
       
        Response.ContentType = GetFileType(doc_type)
           
        Response.AddHeader "ContentType", GetFileType(doc_type)
        Response.AddHeader "Content-Disposition","attachment; filename=" & GetFileName(doc_type)
        Response.BinaryWrite rs_ole.Fields("object_data").GetChunk(rs_ole.Fields("object_data").ActualSize)
        Response.Flush
        Response.End

        rs_ole.close
        set rs_ole = nothing
    End Sub

    Public Function GetFileType(ByVal FileExt)
        'FileExt = LCase(FileExt)
        Dim ContType
        Select Case FileExt
            Case "Microsoft Office Excel Worksheet"
                ContType = "application/vnd.ms-excel"
            Case "Microsoft Word Document"
                ContType = "application/msword"
            Case "Adobe Acrobat 7.0 Document"
                ContType = "application/pdf"
        End Select
        GetFileExt = ContType
    End Function

    Public Function GetFileName(ByVal FileExt)
        'FileExt = LCase(FileExt)
        Dim Filename
        Select Case FileExt
            Case "Microsoft Office Excel Worksheet"
                Filename = "Ergebnis.xls"
            Case "Microsoft Word Document"
                Filename = "Ergebnis.doc"
            Case "Adobe Acrobat 7.0 Document"
                Filename = "Ergebnis.pdf"
        End Select
        GetFileName = Filename
    End Function
    %>
     

     Wenn ich die Files vergleiche steht bei dem heruntergeladenen z.B. noch folgendes zusätzlich drin:

     

    ÐÏࡱá                >  þÿ                                   þÿÿÿ           …     ‡    ‰ 
      ‹            ‘  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýÿÿÿ{  þÿÿÿþÿÿÿýÿÿÿ               
            
                                                                 !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~      €   R o o t   E n t r y                                               ÿÿÿÿÿÿÿÿ   eʸü¡Ð…­DEST              @­cýGAÇ   À        O l e                                                        
     ÿÿÿÿÿÿÿÿÿÿÿÿ                                                C o m p O b j                                                        ÿÿÿÿ                                       ]       C O N T E N T S                                                  ÿÿÿÿÿÿÿÿÿÿÿÿ                                       Р    þÿÿÿ   þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ                 ˜Ý)                                         þÿ
      ÿÿÿÿeʸü¡Ð…­DEST     Acrobat Document        AcroExch.Document.7 ô9²q                                                                                                                                                                                                                                                                                                                                                                                  ‚   ƒ   „   †   ýÿÿÿ‡   ˆ   ‰   Š   ‹   Œ      Ž         ‘   ’   “   ”   •   –   —   ˜   ™   š   ›   œ      ž   Ÿ       ¡   ¢   £   ¤   ¥   ¦   §   ¨   ©   ª   «   ¬   ­   ®   ¯   °   ±   ²   ³   ´   µ   ¶   ·   ¸   ¹   º   »   ¼   ½   ¾   ¿   À   Á      à  Ä   Å   Æ   Ç   È   É   Ê   Ë   Ì   Í   Π  Ï   Р  Ñ   Ò   Ó   Ô   Õ   Ö   ×   Ø   Ù   Ú   Û   Ü   Ý   Þ   ß   à   á   â   ã   ä   å   æ   ç   è   é   ê   ë   ì   í   î   ï   ð   ñ   ò   ó   ô   õ   ö   ÷   ø   ù   ú   û   ü   ý   þ   ÿ      

    Abgelegt unter: ,
    • IP-Adresse ist Registriert
  • 03-29-2007 19:36 Antwort zu

    AW: Problem beim Download von binary Data aus DB

    Oh wie schön, eingefügt als OLE Objekt. Grande Katastrophe. Das kenn' ich von meinen Access Zeiten. Ich hab mir damals eine Komponente geschrieben um das OLE Gedöns wegzustrippen, allerdings den Code werd ich wohl nimma anfinden.

    Chris 

    • IP-Adresse ist Registriert
Seite 1 von 1 (2 Treffer)