response.download expects the last arg in the url to be the filename, so you might be able to pass the image.id as the first arg:
args=[image.id, image.file] Anthony On Thursday, October 27, 2011 11:39:22 AM UTC-4, thodoris wrote: > > Hi, > > I am wondering what is the best way to count how many times a file has > been downloaded. I have the following: > > db.define_table('image', > Field('file', 'upload'), > Field('downloads','integer', default=0,readable=False, > writable=False)) > > I have a view that has the following: > > {{=A("Download", _href=URL('download', args=image.file))}} > > So when Download is clicked the file file will be downloaded. > > The function that is called is: > > def download(): > return response.download(request,db) > > How can i increase the can increase the image.downloads each time a > file is downloaded. > > I don't know how or if it is possible to pass the image.id in download > and increase the counter doing something like: > > item = db.image[request.vars.id] > new_downloads = item.downloads + 1 > item.update_record(downloads=new_downloads) > > I tried passing more arguments to download like args=[image.file, > mage.id] but it fails. Any ideas????