Storing from PDF to IMG

91 views
Skip to first unread message

Max

unread,
Mar 15, 2012, 6:16:44 AM3/15/12
to google-a...@googlegroups.com
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

Jeff Schnitzer

unread,
Mar 15, 2012, 11:34:51 AM3/15/12
to google-a...@googlegroups.com
You must use the Files API to write the generated image to the blobstore.

Jeff

> --
> 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/-/BDSZMmVUHJAJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.

Max

unread,
Mar 15, 2012, 12:03:21 PM3/15/12
to google-a...@googlegroups.com
Where is the file api?
Sorry, I can't understand what you refer to. Could you please push me in the right direction?


Il giorno giovedì 15 marzo 2012 16:34:51 UTC+1, Jeff Schnitzer ha scritto:
You must use the Files API to write the generated image to the blobstore.

Jeff

> To post to this group, send email to google-appengine@googlegroups.com.


> To unsubscribe from this group, send email to

Stuart Langley

unread,
Mar 15, 2012, 5:57:49 PM3/15/12
to google-a...@googlegroups.com

Mike

unread,
Apr 24, 2012, 1:19:38 PM4/24/12
to google-a...@googlegroups.com
Max

Have you figured this out?  I am looking for someone to build me a PDF to Image conversion tool using GAE.  Are you interested?

Mike

Massimiliano

unread,
Apr 25, 2012, 4:44:05 AM4/25/12
to google-a...@googlegroups.com

Hi Mike,
I'm sorry but the conversion Api doesn't work. I'm working on a alternative way, but appengine is facing big problem with the PDF management.

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/-/CAg65cARtncJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.

Computer_Engineer

unread,
Apr 26, 2012, 2:32:33 PM4/26/12
to google-a...@googlegroups.com
Max: What is the problem with conversion API,it's simple!!

Max

unread,
Apr 27, 2012, 4:36:09 AM4/27/12
to google-a...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages