Also, your example code seems to create a GridFS file from an undefined "file" variable. Have you compiled and executed this code? In the future, it may be more helpful to use a separate service to share code, such as
pastebin.com, rather than embed it unformatted within your post body.