Classic ASP: Insert Image from BLOB/file sample code?


#1

Is there sample code showing how to insert image from a BLOB in classic ASP? It would be great to show both methods, from file or memorystream. Thanks!


#2

Hi,

Thank you for considering Aspose.

Retrieving image from a BLOB requires use of numerous .NET classes inside classic ASP that is not the best idea (unless of course you want to implement this functionality yourself). So storing images in files involves much simpler code, you don't even need to use a memory stream since Aspose.Word provides methods to load and insert images directly from files.

Here's a tiny sample of how to insert an image using DocumentBuilder:

Dim doc
Set doc = CreateObject("Aspose.Word.Document")

Dim builder
Set builder = CreateObject("Aspose.Word.DocumentBuilder")

builder.Document = doc

builder.InsertImage_2("Image.jpg")

doc.Save("Result.doc")


#3

Thanks for the answer but all of my images in my db are stored as BLOBS. So I will avoid saving to temp file as of now and try to insert directly from the BLOB.

Looking back to my previous questions, I discussed this issue probably a year ago asking how to do this in Classic ASP also. It has been deleted from this forum. The answer I got was to “… use Document.Save to save into a memory stream, then obtain byte array from that memory stream and store the byte array in the blob field”.

Does this solution hold true now? Before I attempt this, what is the datatype of output/return variable in the document.save method? Is it a variant? What vartype is it?

Thank you.


#4

Sorry, I was asking how to save a rendered doc file into a database and “… use Document.Save to save into a memory stream, then obtain byte array from that memory stream and store the byte array in the blob field” was the Apose developer’s answer.

Now, since all my images are in the database BLOB, I would appreciate it if someone could help me get this function to work in Classic ASP. If not, I guess the only way is to save to temp files first…


#5

Sorry, I was asking how to save a rendered doc file into a database and use Document.Save to save into a memory stream, then obtain byte array from that memory stream and store the byte array in the blob field was the Apose developer’s answer.

Now, since all my images are in the database BLOB, I would appreciate it if someone could help me get this function to work in Classic ASP. If not, I guess the only way is to save to temp files first…