how to do file uploading in turbogears 2.3.1? I am using CrudRestController and tgext.datahelpers and it is uploading the file in the sqlite3 database but in an unknown format. I want to make a copy of the uploaded file in the hard drive. My query is how to ensure that when user uploads a file, it is loaded both in the database and the hard drive. (Thank you for suggestions)
Asked
Active
Viewed 232 times
1 Answers
0
tgext.datahelpers uploads files on disk inside the public/attachments
directory (this can be change with tg.config['attachments_path']
).
So your file is already stored on disk, only the file metadata, like the URL, filename, thumbnail_url and so on are stored on database in JSON
format

amol
- 1,771
- 1
- 11
- 15
-
1actually this is what I expected but it is not happening like this. I created the model and used file = Column(Attachment). Then used this model in the controller (using crudrestcontroller). When I am doing the file uploading it is showing that the file is uploading but nothing is coming on the disk. – neeraj Dec 12 '13 at 04:46
-
i tried to add a document using bootstrap.py and after running gearbox setup-app -c development.ini, the file is added in the database and disk. But after starting the app and going to the page /doc (using crudrestcontroller), the file is not getting added. The db shows that one more row is added but in the file column, nothing is there – neeraj Dec 12 '13 at 06:37
-
It might be related to validator issues. This tutorial mixes CrudRestController and tgext.datahelpers attachments, try to see if it works: http://blog.axant.it/archives/423 – amol Dec 12 '13 at 14:26
-
yes it was related to the validator. I was not using the FileValidator. Thank you very much for ur suggestion. – neeraj Dec 19 '13 at 08:18