SetContentType() public method

Sets the content type for an existing GridFS file.
public SetContentType ( MongoDB.Driver.GridFS.MongoGridFSFileInfo fileInfo, string contentType ) : void
fileInfo MongoDB.Driver.GridFS.MongoGridFSFileInfo The GridFS file.
contentType string The content type.
return void
        public void AttachFile(byte[] data, FileReference fileData, SCORMObject obj)
        {
            List<FileReference> files = new List<FileReference>();
            if (obj.Files != null)
            {
                files.AddRange(obj.Files);
            }

            var db = MongoDB.Driver.MongoDatabase.Create(_ConnectionString);
            var gfs = new MongoGridFS(db);
            var id = Guid.NewGuid().ToString();
            using (var file = gfs.OpenWrite(id))
            {
                file.Write(data, 0, data.Length);
                file.Flush();
            }
            var fileInfo = gfs.FindOne(id);
            gfs.SetContentType(fileInfo, fileData.ContentType);
            fileData.FileId = id;
            files.Add(fileData);
            obj.Files = files;
        }