[web2py] Re: upload and download, in order to manage attached files
On Thursday, May 18, 2017 at 8:42:40 AM UTC-7, J-Michel Angers wrote: > > One step more :-) > Without changing the above code, it's working now. > The change I've written ==> in the DAL, I had "db_codec='latin1' ". I > just removed it for another reason, and it works now. > ... And I understand now the link /default/download/ : it's > / controlleur="default" / function="download" / Params= > > It's OK for this, many thanks Dave for your help. > And I'll open another post, about codec with MS SQL Server. > Glad you're making progress! /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: upload and download, in order to manage attached files
One step more :-) Without changing the above code, it's working now. The change I've written ==> in the DAL, I had "db_codec='latin1' ". I just removed it for another reason, and it works now. ... And I understand now the link /default/download/ : it's / controlleur="default" / function="download" / Params= It's OK for this, many thanks Dave for your help. And I'll open another post, about codec with MS SQL Server. -- 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: upload and download, in order to manage attached files
Thank you Dave for your advices ! You're right, I didn't look at the "download" function, and I didn't change it. I've done this now : (1) I've removed the "auth" condition, and I change the db to dbW = the database for my app I also change the line in the view. New version of download : def download(): """ allows downloading of uploaded files http:///[app]/default/download/[filename] """ return response.download(request, dbW) And for the view : Old version Avec A : {{=A(ligne.Titre, _href=URL('upload',ligne.Document))}} New version : Avec A : {{=A(ligne.Titre, _href=URL('download',args=ligne.Document ))}} But it doesn't work. When i move the mouse on the field, I see at the bottom of the screen : http://127.0.0.1:8000/wfda/default/download/TPJ.Document.bfcea4c64f58c64e.466163743138303832302e706466.pdf I don't understand how the upload/download works : For upload, the default directory is /upload/..xxx.pdf For download, the directory is /default/download/..xxx.pdf Question : the "default/download" come from / ? For me, with my tests, the file is always in /upload. Many thanks for the time you spend with helping developpers :-) -- 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: upload and download, in order to manage attached files
On Wednesday, May 17, 2017 at 9:57:50 AM UTC-7, J-Michel Angers wrote: > > Hi, > I'm building an app to fill "PurchaseRequest", to valid it by the staff, > and then type a "PurchaseOrder". Exactly like with a paper form that we > fill, and get signatures to valid it. > Now the main boby of the app works (fill the form, set/choose the route, > send emails to the concerned persons (by request to the Active Directory), > > > Now I need for this app, to input one or more (or none) attached file > (quotation in PDF format, Excel file, technical data in PDF format)... > I can upload this files, sort them, display the titles, ... > Impossible to show the file. > I see the file in the OS directories (/upload/, where is > TPJ.Document.<.>.extension). > I have a customised html page, but either I get "unknown page", or I get > ... nothing. When I manually copy the link into explorer, I see the file > > [...] > And now the html view.. > > {{=form.custom.begin}} > > > DEMANDE D'ACHAT: {{=form.custom.dspval.id}} > > .. > > {{=form.custom.submit}} > {{=form.custom.end}} > > > > Pièces jointes : > > {{for ligne in PiecesJointes:}} > Avec A : {{=A(ligne.Titre, > _href=URL('upload',ligne.Document))}} > Avec file: "file:\\{{=os.path.join(request.folder,'uploads',ligne.Document)}}"> > {{=ligne.Titre}} > > {{pass}} > > > > > > > > With the "=A(ligne.Titre...", I see the link " > http://127.0.0.1/da/upload/TPJ.Document.blabla.pdf. When I click I get > "404 unknown page" > With the " "file:///C:/Users//da/upload/TPJ.Document.blabla.pdf. When I click, > nothing arrive. When I copy manually the link, and paste into browser > addrress, my pdf file opens. > I must have written something wrong... or I absolutly don't understand the > upload/download. > > Thank you for all informations :) > > I think you would be well off to use the "download" function from the welcome app's default.py. I use that in some apps (in one case, the URL is put into an email sent to the person-who-should-be-handling-the-file) with only minor modifications (the call procedure has an @auth.requires_login(), and the download function has some logging added). Your URL would then be URL("download", args=ligne.Document) (The URL function will default the "app/controller" portion to "da/default/ "). Good luck! /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.