Stephen,

i don't see your usage of file_blob or file_data in the sample.  did you 
mean bild_blob is empty?

last time i implemented file upload on GAE i was writing to blobstore 
(cause cloud storage didn't exist yet).  i haven't ported that code to 
cloud storage....but the blobstore code was *very* fiddly!

may i suggest that you use an HTTP inspector (the network tab in the chrome 
developer tools is a decent one) to see what you are actually posting to 
the server?  that should help you to see what the fields are that are being 
posted and what their names are.  hopefully from there you can make some 
sense of it all.

if you are curious of the blobstore upload code check out 
http://www.web2pyslices.com/slice/show/1388/google-app-engine-blobstore-api-support
  
caution:  GAE has changed a *lot* since that has been written.  there are 
much better ways to do that now i think.

hope that helps a little!

cfh

On Monday, May 5, 2014 11:37:31 AM UTC-7, St. Pirsch 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to