[web2py] Re: direct upload in directory
On Tuesday, April 3, 2018 at 4:45:43 AM UTC-7, Anthony wrote: > > On Tuesday, April 3, 2018 at 6:09:36 AM UTC-4, Dave S wrote: >> >> On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote: >>> >>> Hi, >>> >>> I already use this: >>> >>> stream = open("/teste_en.pdf", 'rb') >>> db.ensaios.insert(codigo_registro="novo ensaio", >>> en_pdf=stream >>> ) >>> >>> >> You're using this to read the file into the uploads table? You haven't >> set "uploadfield=True" on your upload fields, so the model is expecting the >> file to be stored in the uploads directory, and a filename to be filled in >> as the field value. >> > > The above is correct -- you can pass a stream directly to .insert() and > the DAL will store the file in the filesystem and the (transformed) > filename in the database field. See > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads > . > > Anthony > I've read that section before, so it's strange that I don't recognize that part. Maybe I'll learn it the second^Wthird time around. /dps -- 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.
[web2py] Re: direct upload in directory
On Tuesday, April 3, 2018 at 6:09:36 AM UTC-4, Dave S wrote: > > On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote: >> >> Hi, >> >> I already use this: >> >> stream = open("/teste_en.pdf", 'rb') >> db.ensaios.insert(codigo_registro="novo ensaio", >> en_pdf=stream >> ) >> >> > You're using this to read the file into the uploads table? You haven't > set "uploadfield=True" on your upload fields, so the model is expecting the > file to be stored in the uploads directory, and a filename to be filled in > as the field value. > The above is correct -- you can pass a stream directly to .insert() and the DAL will store the file in the filesystem and the (transformed) filename in the database field. See http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads. Anthony -- 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.
Re: [web2py] Re: direct upload in directory
thanks. db(db.ensaios.codigo_registro == "novo ensaio").update(en_pdf=stream) works for me!! thanks again! 2018-04-03 7:09 GMT-03:00 Dave S : > On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote: >> >> Hi, >> >> I already use this: >> >> stream = open("/teste_en.pdf", 'rb') >> db.ensaios.insert(codigo_registro="novo ensaio", >> en_pdf=stream >> ) >> >> > You're using this to read the file into the uploads table? You haven't > set "uploadfield=True" on your upload fields, so the model is expecting the > file to be stored in the uploads directory, and a filename to be filled in > as the field value. > > >> >> but I need to know if is a possible update a row with an upload. >> >> > I would think so, but the most common usage seems to be just to make a new > entry with every upload, with the form.process.accepted doing an insert, > except if you've set the record parameter to SQLFORM(). See > http://web2py.com/books/default/chapter/29/07/forms- > and-validators#SQLFORM-and-insert-update-delete> > (and a brief mention in the SQLFORM() signature a couple paragraphs above)/ > > You may want to show us the controller code you are using if this doesn't > answer your questions. > > /dps > > >> >> 2018-04-02 14:27 GMT-03:00 Diego Tostes : >> >>> >>> >>> 2018-04-02 13:22 GMT-03:00 Diego Tostes : >>> Hi, i have a table in my model called ensaios: Ensaios = db.define_table('ensaios', Field('codigo_registro', 'string'), Field('url', 'string'), Field('titulo_pt', 'string'), Field('titulo_en', 'string'), Field('tags', 'text'), Field('contato_publico', 'string'), Field('email_contato_publico', 'string'), Field('pt_pdf', 'upload'), Field('en_pdf', 'upload'), Field.Virtual('relatorio', lambda row: A('Relatorio', _href=URL('default', 'ensaios', vars=dict(ensaio_id= row.ensaios.id, ) i will store pdfs from clinical trials. the problem is that i already have more than 5000 pdfs. i tried to put all the pdfs inside of the "web2py/applications/ensaiosclinicos/uploads" and did insertions of the names of the files in the database. But I am getting a error : 404 NOT FOUND Is it possible to do this ? rgds Diego >>> >> -- > 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.
[web2py] Re: direct upload in directory
On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote: > > Hi, > > I already use this: > > stream = open("/teste_en.pdf", 'rb') > db.ensaios.insert(codigo_registro="novo ensaio", > en_pdf=stream > ) > > You're using this to read the file into the uploads table? You haven't set "uploadfield=True" on your upload fields, so the model is expecting the file to be stored in the uploads directory, and a filename to be filled in as the field value. > > but I need to know if is a possible update a row with an upload. > > I would think so, but the most common usage seems to be just to make a new entry with every upload, with the form.process.accepted doing an insert, except if you've set the record parameter to SQLFORM(). See http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-and-insert-update-delete> (and a brief mention in the SQLFORM() signature a couple paragraphs above)/ You may want to show us the controller code you are using if this doesn't answer your questions. /dps > > 2018-04-02 14:27 GMT-03:00 Diego Tostes >: > >> >> >> 2018-04-02 13:22 GMT-03:00 Diego Tostes >: >> >>> Hi, >>> >>> >>> i have a table in my model called ensaios: >>> >>> Ensaios = db.define_table('ensaios', >>> Field('codigo_registro', 'string'), >>> Field('url', 'string'), >>> Field('titulo_pt', 'string'), >>> Field('titulo_en', 'string'), >>> Field('tags', 'text'), >>> Field('contato_publico', 'string'), >>> Field('email_contato_publico', 'string'), >>> Field('pt_pdf', 'upload'), >>> Field('en_pdf', 'upload'), >>> Field.Virtual('relatorio', lambda row: A('Relatorio', >>> _href=URL('default', >>> 'ensaios', >>> vars=dict(ensaio_id= >>> row.ensaios.id, >>> ) >>> >>> >>> i will store pdfs from clinical trials. the problem is that i already >>> have more than 5000 pdfs. >>> >>> i tried to put all the pdfs inside of the >>> "web2py/applications/ensaiosclinicos/uploads" >>> >>> and did insertions of the names of the files in the database. But I am >>> getting a error : >>> >>> 404 NOT FOUND >>> >>> Is it possible to do this ? >>> >>> >>> rgds >>> >>> Diego >>> >>> >>> >> > -- 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.
[web2py] Re: direct upload in directory
On Monday, April 2, 2018 at 9:22:51 AM UTC-7, Diego Tostes wrote: > > Hi, > > > i have a table in my model called ensaios: > > Ensaios = db.define_table('ensaios', > Field('codigo_registro', 'string'), > Field('url', 'string'), > Field('titulo_pt', 'string'), > Field('titulo_en', 'string'), > Field('tags', 'text'), > Field('contato_publico', 'string'), > Field('email_contato_publico', 'string'), > Field('pt_pdf', 'upload'), > Field('en_pdf', 'upload'), > Field.Virtual('relatorio', lambda row: A('Relatorio', > _href=URL('default', > 'ensaios', > vars=dict(ensaio_id= > row.ensaios.id, > ) > > > i will store pdfs from clinical trials. the problem is that i already have > more than 5000 pdfs. > > i tried to put all the pdfs inside of the > "web2py/applications/ensaiosclinicos/uploads" > > and did insertions of the names of the files in the database. But I am > getting a error : > > 404 NOT FOUND > > What are you doing that returns a 404 error? Is this during the insertion or during an attempt to retrieve the file? > Is it possible to do this ? > > I mostly have the problem going the other way ... deleting rows (and their files) that are either development-test files or excessibely obsolete. > > rgds > > Diego > > Dave /dps -- 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.
[web2py] Re: direct upload in directory
Hi, I already use this: stream = open("/teste_en.pdf", 'rb') db.ensaios.insert(codigo_registro="novo ensaio", en_pdf=stream ) but I need to know if is a possible update a row with an upload. 2018-04-02 14:27 GMT-03:00 Diego Tostes : > > > 2018-04-02 13:22 GMT-03:00 Diego Tostes : > >> Hi, >> >> >> i have a table in my model called ensaios: >> >> Ensaios = db.define_table('ensaios', >> Field('codigo_registro', 'string'), >> Field('url', 'string'), >> Field('titulo_pt', 'string'), >> Field('titulo_en', 'string'), >> Field('tags', 'text'), >> Field('contato_publico', 'string'), >> Field('email_contato_publico', 'string'), >> Field('pt_pdf', 'upload'), >> Field('en_pdf', 'upload'), >> Field.Virtual('relatorio', lambda row: A('Relatorio', >> _href=URL('default', >> 'ensaios', >> vars=dict(ensaio_id= >> row.ensaios.id, >> ) >> >> >> i will store pdfs from clinical trials. the problem is that i already >> have more than 5000 pdfs. >> >> i tried to put all the pdfs inside of the >> "web2py/applications/ensaiosclinicos/uploads" >> >> >> and did insertions of the names of the files in the database. But I am >> getting a error : >> >> 404 NOT FOUND >> >> Is it possible to do this ? >> >> >> rgds >> >> Diego >> >> >> > -- 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.
[web2py] Re: direct upload in directory
2018-04-02 13:22 GMT-03:00 Diego Tostes : > Hi, > > > i have a table in my model called ensaios: > > Ensaios = db.define_table('ensaios', > Field('codigo_registro', 'string'), > Field('url', 'string'), > Field('titulo_pt', 'string'), > Field('titulo_en', 'string'), > Field('tags', 'text'), > Field('contato_publico', 'string'), > Field('email_contato_publico', 'string'), > Field('pt_pdf', 'upload'), > Field('en_pdf', 'upload'), > Field.Virtual('relatorio', lambda row: A('Relatorio', > _href=URL('default', > 'ensaios', > vars=dict(ensaio_id=row. > ensaios.id, > ) > > > i will store pdfs from clinical trials. the problem is that i already have > more than 5000 pdfs. > > i tried to put all the pdfs inside of the > "web2py/applications/ensaiosclinicos/uploads" > > > and did insertions of the names of the files in the database. But I am > getting a error : > > 404 NOT FOUND > > Is it possible to do this ? > > > rgds > > Diego > > > -- 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.