Really Simple!
This is my code:

class FAX(db.Expando):
    date = db.DateTimeProperty(auto_now_add=True)


class LogSenderHandler(InboundMailHandler):
    def receive(self, mail_message):
        for elemento in mail_message.attachments:
            asset = conversion.Asset("application/pdf", str(elemento[1]), 
"Fax.pdf")
            conversion_obj = conversion.Conversion(asset, "image/png")
            result = conversion.convert(conversion_obj)
            for elemento2 in result.assets:
                fax = FAX()
                fax.immagine = elemento2.data
                fax.put()


def main():
    application = webapp.WSGIApplication([LogSenderHandler.mapping()], debug
=True)
    wsgiref.handlers.CGIHandler().run(application)


if __name__ == '__main__':
        main()

This is my code. It must work, but it doesn't.


Il giorno giovedì 26 aprile 2012 20:32:33 UTC+2, Computer_Engineer ha 
scritto:
>
> Max: What is the problem with conversion API,it's simple!!
> *
> *
> On Thursday, March 15, 2012 12:16:44 PM UTC+2, Max wrote:
>>
>> Dear All,
>> I'm always storing the img I receive in the blobstore using this code:
>>
>> class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
>>  def post(self):
>>  upload_files = self.get_uploads('File')
>>  blob_info = upload_files[0]
>>  fotos = FOTO()
>>  fotos.link = blob_info.key()
>>  fotos.Tlink = images.get_serving_url(fotos.link, 94)
>>  fotos.Glink = images.get_serving_url(fotos.link, 800)
>>  fotos.put()
>>
>> Now I receive a PDF and I have to store an IMG.
>> And I'm thinking to use the conversions tool as per below.
>>
>> from google.appengine.api import conversion
>>
>> # Create a conversion request from HTML to PNG.
>> asset = conversion.Asset("text/html", "<b>some data</b>", "test.html")
>> conversion_obj = conversion.Conversion(asset, "image/png")
>>
>> result = conversion.convert(conversion_obj)
>> if result.assets:
>>   # Note: in most cases, we will return data all in one asset.
>>   # Except that we return multiple assets for multiple pages image.
>>   for asset in result.assets:
>>     doSomethingWithAsset(asset.data)
>> else:
>>   handleError(result.error_code, result.error_text)
>>
>>
>> My question is:
>> How can I store the asset? Could I still use the way I was?
>>
>> Thanks
>>
>> Max
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/WqjgenoLFqwJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to