Download a BLOB directly from Database without temporary files or chunks
Posted: 2002-06-01
By: ArchiveBot
Viewed: 78
Filed Under:
No attachments for this post
Download a binary large object (BLOB) from the database without temporary files or chunks.
Original Author: Thommy
Code
'Declarations
Dim objStream 'As ADODB.Stream
Dim objBLOB 'As Object
Dim strBLOB 'As String
Dim lngBLOB 'As Long
'Create objects
Set objStream = Server.CreateObject("ADODB.Stream")
'Get the object, the object size and the object name from the database
'Set objBLOB = ... 'Get the BLOB out of the database
'strBLOB = ... 'Filename to be saved to
'lngBLOB = ... 'Length of the BLOB
'Assign object to stream
With objStream
.Type = 1
.Open
.Write objBLOB
.Position=0
End With
'Start forcing download
With Response
.AddHeader "Content-Disposition", "attachment; filename=" & strBLOB
.AddHeader "Content-Length", lngBLOB
.ContentType = "binary/octet-stream"
.BinaryWrite objStream.Read
.Flush
End With
'Close all objects
objStream.Close
'Clean up
Set objStream = Nothing
Set objBLOB = Nothing
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.