Advertisement
Java_Volume1 String Manipulation #102315

Download a BLOB directly from Database without temporary files or chunks

Download a binary large object (BLOB) from the database without temporary files or chunks.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'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
Original Comments (3)
Recovered from Wayback Machine