Пример #1
0
        public void TestSetContentType()
        {
            var fileInfo = UploadHelloWorld();

            Assert.IsNull(fileInfo.ContentType);

            _gridFS.SetContentType(fileInfo, "text/plain");
            fileInfo.Refresh();
            Assert.AreEqual("text/plain", fileInfo.ContentType);

            _gridFS.SetContentType(fileInfo, null);
            fileInfo.Refresh();
            Assert.IsNull(fileInfo.ContentType);
        }
Пример #2
0
        public string InserirArquivo(Stream arquivo, string nome, string contentType)
        {
            var mySetting = new MongoGridFSSettings();
            var gfs       = new MongoGridFS(server, database.Name, mySetting);
            var fileInfo  = gfs.Upload(arquivo, nome);

            gfs.SetContentType(fileInfo, contentType);
            return(fileInfo.Id.AsObjectId.ToString());
        }