My advice is do not do this manually because it is complicated db.define_table('mytable',Field('image','upload',uploadfield='ablob'))
this automatically creates a Field('ablob','blob') where it stores images. Field('image') stores a tmp name for uploaded images including the original extension. When you download/<image> it will set the content-type to the original one and the content-disposition to the original filename. On Dec 28, 4:58 pm, Hasanat Kazmi <hasanatka...@gmail.com> wrote: > I have a quick question, how do I show an image stored in database (as > blob; the default used in web2py when image is stored using crud) > like, if some one embeds link like /image/24 , it shows image not > html (i mean, content type is automatically set)? > > On Nov 19, 10:02 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > for now you can do: > > > import base64 > > rows=db(db.tablename.id>0).select() > > for row in rows: > > row.blobfield=base64.b64encode(row.blobfield) > > rows.export_to_csv_file(file) > > > On Nov 19, 10:52 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > This needs to be fixed. It is tricky to do but I will put on the todo > > > list. > > > > On Nov 19, 10:14 am, ecall <edouard.call...@gmail.com> wrote: > > > > > I'm trying to export/import database having an "upload" field stored > > > > as ablobrefered by a "uploadfield". > > > > Infortunatly, theblobis saved as binary data, this makes the CSV > > > > file useless... I was expecting that was base64 data. > > > > > Is there a way to tell "export_to_csv_file()" to use base64 for the > > > >blob? > > > > > Thx > > > > Edouard > > > > > On Nov 18, 1:41 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > what do you mean by "calling"? The garbage is theimage. > > > > > > On Nov 17, 11:39 pm, David <digitalcry...@gmail.com> wrote: > > > > > > > I was storing the images in postgres. When I tried calling theimage > > > > > > by the filename it returned the coded filename. When I tried > > > > > > calling > > > > > > theimageblobit returned garbage. > > > > > > > I was just wondering if there was an example on how to call the > > > > > > images > > > > > > from the database as it isn't mentioned in the manual and I don't > > > > > > know > > > > > > what takes place on GAE. > > > > > > > On Nov 17, 7:35 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > > This is all automatic in web2py is you do not rename the uploaded > > > > > > > files. > > > > > > > > On Nov 17, 7:18 pm, Beerc <berces.las...@fomi.hu> wrote: > > > > > > > > > Storing images in database is a bad idea GENERALLY. > > > > > > > > But on GAE you can't write the file system, so you have no other > > > > > > > > choice for persistent storage. > > > > > > > > > And you will see garbage instead ofimageif MIME type incorrect > > > > > > > > or > > > > > > > > unsetted. > > > > > > > > In general case the web server (e.g. Apache) will set it for you > > > > > > > > automatically (if its configuration is correct). > > > > > > > > But if YOU serve the files (as in case of GAE) instead of the > > > > > > > > web > > > > > > > > server, then you must to set the MIME type in the HTTP header. > > > > > > > > Example > > > > > > > > for a JPEG file: > > > > > > > > Content-Type:image/jpg > > > > > > > > Seehttp://en.wikipedia.org/wiki/MIMEfordetails. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.