thank you. I needed it too

On Wednesday, December 15, 2010 at 9:27:58 PM UTC+3, azarkowsky wrote:
>
> Thanks everybody for your suggestions!  I went with what Bruno 
> suggested and it worked like a champ!   I figured I wouldn't be able 
> to bypass the upload security mechanism, but the uploadfolder 
> parameter was the key piece I needed to get the desired behavior. 
>
> On Dec 14, 11:57 am, Bruno Rocha <[email protected]> wrote: 
> > For security reasons, web2py does not expose the 'uploads' folder to the 
> > user, this folder can be accessed only by the 'download' function. 
> > 
> > You can do that: 
> > 
> > change the upload folder with 'uploadfolder' parameter. 
> > 
> > <model> 
> > db.define_table('pdfs', 
> > 
> > Field('file','upload',uploadfolder=request.folder+'static/pdfs') 
> >                        ) 
> > </model> 
> > 
> > Create a viewer function wich redirects the user direct to the file, 
> then, 
> > if the user has adobe acrobat plugin to view the file in browser, this 
> file 
> > will be shown in the browser, else, will be downloaded. 
> > 
> > <controller> 
> > def viewer(): 
> >     row = db(db.pdfs.id==request.args(0)).select(db.pdfs.file).first() 
> >     redirect(URL('static','pdfs',args=row.file)) 
> > </controller> 
> > 
> > Now you can call this as: 
> > 
> > http://127.0.0.1:8000/pdfs/default/viewer/3#record id 
> > 
> > which redirects the user to:
> http://127.0.0.1:8000/pdfs/static/pdfs/pdfs.file.aaf5d3f7779841d0.6e6... 
> > 
> > -- 
> > 
> > Bruno Rochahttp://about.me/rochacbruno/bio 
> > 
> > 2010/12/14 azarkowsky <[email protected]> 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > In my web2py application I'm allowing users to upload PDF documents 
> > > (via an upload field) and then on another page I provide a download 
> > > link, however, I think because of the file renaming security feature 
> > > these PDF documents are truly being downloaded again (saved locally to 
> > > each user's desktop) instead of just displayed in a new browser window 
> > > as is the case with most other PDFs I encounter on other websites.  Is 
> > > there any way to provide a link directly to a file that was uploaded 
> > > so the browser can display it without having to download the file 
> > > again? 
> > 
> > > Thanks, 
> > > Adam

-- 
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