I am working on the same thing but for sounds. I used the experimental file 
writing to blobstore liker this:

def blobstore_upload(form):
    from google.appengine.api import files
    from google.appengine.ext import blobstore
    if request.env.web2py_runtime_gae and form.vars.file:
        # Create the file
        file_name = 
files.blobstore.create(mime_type='application/octet-stream')

        # Open the file and write to it
        with files.open(file_name, 'a') as f:            
            f.write(form.vars.file.file.read())

        # Finalize the file. Do this before attempting to read it.
        files.finalize(file_name)

        # Get the file's blob key        
        form.vars.blob_key = files.blobstore.get_blob_key(file_name)        
        form.vars.file = None

@auth.requires_login()
def upload():
    return dict(form=crud.update(db.sounds, a0, 
onvalidation=blobstore_upload, message=T('Upload complete!')))

def download_blob():        
    from google.appengine.ext import blobstore
    sound = db.sounds(a0)
    if not sound:
        raise HTTP(404)
    blob_info = blobstore.BlobInfo.get(sound.blob_key)
    return response.stream(blob_info.open())

Now I am hitting the 10Mb limit so I need to experiment some more with 
create_upload_url.

-rif

miercuri, 7 martie 2012, 11:36:40 UTC+2, Sushant Taneja a scris:
>
> Hi,
>
> I am trying to use the Google Blobstore API for uploading images. I also 
> checked the link: http://www.web2pyslices.com/main/slices/take_slice/63 for 
> the help but couldn't understand much.
>
> In my application's (uploadPic) default controller I have the code as 
> follows:
>
> from google.appengine.ext import blobstore
>
> def index():
>     """
>     This provides the upload_url to the upload form
>     """
>     
> upload_url=blobstore.create_upload_url(URL('uploadPic','default','pic'))
>     return dict(upload_url=upload_url)
>
> def pic():
>     """
>     This method stores the bolb key in a table and is used for serving the 
> BLOB images
>     """
>     response.write(request)
>
> In the view index.html, I have a simple form
>
> <html>
>     <body>
>         <form method='post' action='{{=upload_url}}' 
> enctype='multipart/form-data'>
>             <input type='file' name='file'>
>             <input type='submit' name='submit' value='Upload'>
>         </form>
>     </body>
> </html>
>
> As per my understanding, when the upload is successful, GAE automatically 
> redirects to the URL provided in the create_upload_url function with the 
> request containing the blob_key.
>
> But when I execute the above, all I get in the page is None. The log is 
> showing the following:
>
> INFO     2012-03-07 09:30:31,188 dev_appserver.py:2865] "GET 
> /uploadPic/default/index HTTP/1.1" 200 -
> INFO     2012-03-07 09:30:37,558 dev_appserver.py:687] Internal 
> redirection to /uploadPic/default/pic
> INFO     2012-03-07 09:30:37,681 gaehandler.py:69] **** Request: 
> 104.29ms/100.00ms (real time/cpu time)
> INFO     2012-03-07 09:30:37,686 recording.py:372] Saved; key: 
> __appstats__:037500, part: 20 bytes, full: 1234 bytes, overhead: 0.000 + 
> 0.004; link: http://localhost:8080/_ah/stats/details?time=1331112637576
> INFO     2012-03-07 09:30:37,695 dev_appserver_blobstore.py:447] Upload 
> handler returned 200
> INFO     2012-03-07 09:30:37,723 dev_appserver.py:2865] "POST 
> /_ah/upload/ag9kZXZ-aW1hZ2V1cGxvYWRyGwsSFV9fQmxvYlVwbG9hZFNlc3Npb25fXxggDA 
> HTTP/1.1" 200 -
>
> Can someone please help me understand it ? 
>
> Thanks,
> Sushant
>
>
>

Reply via email to