On Aug 16, 2007, at 10:02 PM, SamDonaldson wrote:

>
> Actually, what I'd like to be able to do is not physically create a
> file.  I'd like to just hold that buf as a file object in memory on
> which the read/write api's can get applied.  In other words, I don't
> want a somefile.jpg on my filesystem.  I want to pass that buffer as a
> file object on to some other layer in my code that will take care of
> making that a file, similar to what I do with the
>
> 'file' attribute in the FieldStorage object.
>
> On Aug 16, 8:40 pm, Jose Galvez <[EMAIL PROTECTED]> wrote:
>>
>> SamDonaldson wrote:
>>> Guys, I have one short question and this relates to the FieldStorage
>>> Pylons file object in the way it represents a posted image.  Does
>>> anybody know what the 'file' attribute's type is in the object on
>>> which read/write/close is invoked?  I'm trying to do the following:
>>
>>> I'm reading in binary data from somewhere into memory, and I want to
>>> now convert that into an image file.  What are the steps to do that:
>>
>>> buf = urllib.urlopner(....).read()
>>> f = open(buf, 'wb')
>

urllib.urlopen returns the file-like object that you want, directly.  
read() is reading the response data from it, what you've done here is  
open a new file with a junk filename.

--
Philip Jenvey



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to