Why not implement your own create and update form with SQLFORM and once the
record get create you can just copy the file form googlestore to your
google could?

You can retrieve the original file name with
db.table.field_upload.retrieve(db.table(id).field_upload)

And you should be able to get your file db.table(id).field_upload_blob

Not sure all the particularities of googlestore thought...

You can have a look at the code of the gluon/dal.py .store(), .retrieve(),
.retrieve_file_properties method.

Hope it helps

Richard


On Mon, May 5, 2014 at 2:37 PM, St. Pirsch <spir...@gmail.com> wrote:

> Hi,
> I'm trying to catch image data on upload to GAE, in order to store it in
> the google cloud.
>
> My model:
> db.define_table('fragen',
>     ...
>     Field('bild','upload'),
>     ...
> As far as I understand, web2py generates a blob field automatically on GAE
> enviroment, so I didn't implement it in the model.
>
>
> My cloud-upload controller looks like this:
> def cloudupload(form):
>     from google.appengine.api import app_identity
>     bucket_name = os.environ.get('BUCKET_NAME',
> app_identity.get_default_gcs_bucket_name())
>     bucket = '/' + bucket_name
>     filename = bucket + '/'+ str(form.vars.bild)
>     from gluon import contenttype
>     mime = contenttype.contenttype(form.vars.bild)
>     my_default_retry_params = gcs.RetryParams(initial_delay=0.2,
>                                           max_delay=5.0,
>                                           backoff_factor=2,
>                                           max_retry_period=15)
>     gcs.set_default_retry_params(my_default_retry_params)
>     write_retry_params = gcs.RetryParams(backoff_factor=1.1)
>     gcs_file = gcs.open(filename,
>                         'w',
>                         content_type= mime,
>                         retry_params=write_retry_params)
>     gcs_file.write(form.vars.bild_blob)
>     gcs_file.close()
>     return()
>
> I'm calling it from a form a grid. I have tried 'onvalidate= first', but
> the fieldstorage doesn't provide me with the filename web2py is storing
> finally in the "image" field. So I employed oncreate.
>
> def fragen_cms():
>     '''
>     Eingabe für die Fragen
>     '''
>     grid = SQLFORM.smartgrid(db.fragen, orderby=db.fragen.contents,
> oncreate=cloudupload)
>     return dict(grid=grid)
>
> Image name is fine, cloud upload works as well, but it seems that there is
> no data in file_blob, nor in file_data. Is there a way to retrieve the file
> from the form?
>
> Thanks for Your help,
> Stephan
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to