GridFS file exists with with name?

306 views
Skip to first unread message

kevin

unread,
Jun 7, 2010, 3:25:22 PM6/7/10
to mongod...@googlegroups.com
can you guys add a method to check if a file already exists with a given file name? or make get_last_version return None if filename does not exist?

i want to check if a file with a filename exists otherwise i want to fetch and insert into GridFS. but there is no method to check if a file with filename exists?
thanks

Eliot Horowitz

unread,
Jun 7, 2010, 4:24:53 PM6/7/10
to mongod...@googlegroups.com
Which driver/package are you referring to?

> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.
>

kevin

unread,
Jun 7, 2010, 4:37:13 PM6/7/10
to mongod...@googlegroups.com
pymongo

Michael Dirolf

unread,
Jun 7, 2010, 4:40:48 PM6/7/10
to mongod...@googlegroups.com
get_last_version raises NoFile if no such file exists, so you can just
catch that. Or you can manually query the files collection looking for
the filename

kevin

unread,
Jun 7, 2010, 5:38:17 PM6/7/10
to mongod...@googlegroups.com
it will be nice/convenient if the filesystem supported a method to check if there is a file with filename instead of trying to catch exceptions, or try to read fs.files collection

Michael Dirolf

unread,
Jun 7, 2010, 5:40:05 PM6/7/10
to mongod...@googlegroups.com
Feel free to file a jira should be easy to add.

kevin

unread,
Jun 7, 2010, 5:43:55 PM6/7/10
to mongod...@googlegroups.com

Michael Dirolf

unread,
Jun 7, 2010, 5:44:36 PM6/7/10
to mongod...@googlegroups.com
great - thanks

kevin

unread,
Jun 29, 2010, 10:06:42 PM6/29/10
to mongod...@googlegroups.com
wouldn't it be better if it returns the file instance or None instead of True or False?
http://jira.mongodb.org/browse/PYTHON-138
Reply all
Reply to author
Forward
0 new messages