FAQ
Hello!

I'm writing ASP in Python.
I want to return an image stream from my ASP code
so that it will look like
<img src="image.asp">.

The problem is that Response.BinaryWrite only accepts SafeArray of Bytes as
parameter, if I understand it correctly.
How can I do it?

The example will be like this.

Response.Expires = 0
Response.Buffer = True
Response.Clear()
Response.ContentType = "image/gif"

Response.BinaryWrite(get_image()) #the function is below.

Response.End()
----------
def get_image():
f = open(file_name, "rb")
s = f.read()
f.close()
return s

Thanks in advance.

kong

Search Discussions

  • Peter Hansen at Jun 11, 2004 at 11:03 am

    Sam Sungshik Kong wrote:

    I'm writing ASP in Python.
    I want to return an image stream from my ASP code
    so that it will look like
    <img src="image.asp">.

    The problem is that Response.BinaryWrite only accepts SafeArray of Bytes as
    parameter, if I understand it correctly.
    This sounds a lot more like an ASP question than a Python
    one, given that you already know how to read the image
    file into a Python string. It looks like you need some
    method for converting the string to a SafeArray, whatever
    that is, so you should probably consult the API for the
    interface you are using, maybe on the Microsoft site...

    -Peter
  • Mark Hammond at Jun 21, 2004 at 12:22 am

    Sam Sungshik Kong wrote:
    Hello!

    I'm writing ASP in Python.
    I want to return an image stream from my ASP code
    so that it will look like
    <img src="image.asp">.

    The problem is that Response.BinaryWrite only accepts SafeArray of Bytes as
    parameter, if I understand it correctly.
    What problem specifically?
    How can I do it?
    Passing a string *should* work. If not, try passing "buffer(string)"

    Mark.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 11, '04 at 6:25a
activeJun 21, '04 at 12:22a
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase