Google App Engine, How to make native file object?

前端 未结 2 796
终归单人心
终归单人心 2021-01-25 02:16

I\'m trying to convert some data got from urlfetch to native python file object. Does anyone know how to do this?

I understand GAE can\'t save files to local. But I need

相关标签:
2条回答
  • 2021-01-25 02:26

    You can use python's StringIO class to wrap a a file-like object around any data retrieved by URL Fetch.

    If you use python's urllib2.urlopen() instead of Google's URL Fetch API, you'll get a file-like object which might work with your library.

    0 讨论(0)
  • 2021-01-25 02:40

    If you just need a file-like object, you can use urllib2, which on GAE is a wrapper around urlfetch. urlopen returns the file-like object. I don't know of a way you could get a true file handle for a downloaded URL.

    0 讨论(0)
提交回复
热议问题