本文整理汇总了C#中MongoDB.Driver.GridFS.MongoGridFS类的典型用法代码示例。如果您正苦于以下问题:C# MongoGridFS类的具体用法?C# MongoGridFS怎么用?C# MongoGridFS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MongoGridFS类属于MongoDB.Driver.GridFS命名空间,在下文中一共展示了MongoGridFS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MongoGridFSFileInfo
internal MongoGridFSFileInfo(
MongoGridFS gridFS,
BsonDocument fileInfo
) {
this.gridFS = gridFS;
CacheFileInfo(fileInfo);
}
示例2: TestConstructorFreezesSettings
public void TestConstructorFreezesSettings()
{
var settings = new MongoGridFSSettings();
Assert.False(settings.IsFrozen);
var gridFS = new MongoGridFS(_server, _database.Name, settings);
Assert.True(gridFS.Settings.IsFrozen);
}
示例3: ConstructorFeezesSettingsTest
public void ConstructorFeezesSettingsTest() {
var settings = new MongoGridFSSettings();
settings.IsFrozen.Should().Be.False();
var gridFS = new MongoGridFS(Database, settings);
gridFS.Settings.IsFrozen.Should().Be.True();
}
示例4: MongoGridFSFileInfo
public MongoGridFSFileInfo(
MongoGridFS gridFS,
string remoteFileName
)
: this(gridFS, remoteFileName, gridFS.Settings.DefaultChunkSize)
{
}
示例5: Upload
/// <summary>
/// Store a file in the database
/// </summary>
/// <param name="stream">The stream of the files content</param>
/// <param name="fileName">The remote filename</param>
/// <param name="contentType">The file's content type</param>
/// <returns>GridFS File Info</returns>
public MongoGridFSFileInfo Upload(Stream stream, string fileName, string contentType)
{
MongoGridFS fs = new MongoGridFS(this.store);
MongoGridFSCreateOptions options = new MongoGridFSCreateOptions();
options.ContentType = contentType;
return fs.Upload(stream, fileName, options);
}
示例6: MongoReaderPlugin
/// <summary>
/// Create a MongoReaderPlugin with an existing MongoDatabase and specific settings for GridFS
/// </summary>
/// <param name="prefix">The virtual folder representing GridFS assets</param>
/// <param name="db">An existing MongoDatabase instance</param>
/// <param name="gridSettings">
/// Settings for the GridFS connection
/// <see href="http://api.mongodb.org/csharp/1.8/html/7a3abd48-0532-8e7f-3c05-6c9812eb06f8.htm" />
/// </param>
public MongoReaderPlugin(string prefix, MongoDatabase db, MongoGridFSSettings gridSettings)
{
_db = db;
_gridSettings = gridSettings;
_grid = _db.GetGridFS(gridSettings);
VirtualFilesystemPrefix = prefix;
}
示例7: Queue
/// <summary>
/// Construct MongoQueue
/// </summary>
/// <param name="collection">collection</param>
/// <exception cref="ArgumentNullException">collection is null</exception>
public Queue(MongoCollection collection)
{
if (collection == null) throw new ArgumentNullException("collection");
this.collection = collection;
this.gridfs = collection.Database.GetGridFS(MongoGridFSSettings.Defaults);
}
示例8: Add
/// <summary>
/// 添加本地文件
/// </summary>
/// <param name="filePath">本地文件路径</param>
/// <param name="remoteFile">服务Id</param>
/// <returns></returns>
public MetaInfo Add(string filePath, string remoteFile)
{
try
{
_logger.DebugFormat("Add File filePath:{0}, remoteId:{1}", filePath, remoteFile);
MongoGridFSCreateOptions option = new MongoGridFSCreateOptions
{
Id = remoteFile,
UploadDate = DateTime.Now,
ContentType = MimeMapper.GetMimeMapping(filePath),
};
using (var stream = new FileStream(filePath, FileMode.Open))
{
MongoGridFS fs = new MongoGridFS(_context.DataBase);
var info = fs.Upload(stream, remoteFile, option);
return new MetaInfo
{
fileName = remoteFile,
MD5 = info.MD5,
MimeType = info.ContentType,
};
}
}
catch (Exception ex)
{
_logger.Error(ex.Message);
_logger.Error(ex.StackTrace);
throw;
}
}
示例9: TestConstructorFeezesSettings
public void TestConstructorFeezesSettings()
{
var settings = new MongoGridFSSettings();
Assert.IsFalse(settings.IsFrozen);
var gridFS = new MongoGridFS(_database, settings);
Assert.IsTrue(gridFS.Settings.IsFrozen);
}
示例10: MongoGridFSTests
public MongoGridFSTests()
{
_server = LegacyTestConfiguration.Server;
_database = LegacyTestConfiguration.Database;
_gridFS = _database.GridFS;
_gridFS.Chunks.RemoveAll();
_gridFS.Files.RemoveAll();
}
示例11: TestFixtureSetup
public void TestFixtureSetup() {
server = MongoServer.Create("mongodb://localhost/?safe=true");
database = server["onlinetests"];
var settings = new MongoGridFSSettings {
ChunkSize = 16,
SafeMode = SafeMode.True
};
gridFS = database.GetGridFS(settings);
}
示例12: OnTestFixtureSetUp
protected override void OnTestFixtureSetUp() {
base.OnTestFixtureSetUp();
var settings = new MongoGridFSSettings
{
ChunkSize = 16,
SafeMode = SafeMode.True
};
gridFS = Database.GetGridFS(settings);
}
示例13: BookContext
public BookContext()
{
string connectionString = ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString;
var con = new MongoUrlBuilder(connectionString);
client = new MongoClient(connectionString);
database = client.GetDatabase(con.DatabaseName);
gridFS = new MongoGridFS(new MongoServer(new MongoServerSettings { Server = con.Server }),con.DatabaseName, new MongoGridFSSettings());
}
示例14: MongoGridFSStreamTests
public MongoGridFSStreamTests()
{
_database = LegacyTestConfiguration.Database;
var settings = new MongoGridFSSettings
{
ChunkSize = 16,
WriteConcern = WriteConcern.Acknowledged
};
_gridFS = _database.GetGridFS(settings);
}
示例15: MongoGridFSFileInfo
public MongoGridFSFileInfo(
MongoGridFS gridFS,
string remoteFileName,
int chunkSize
)
{
this.gridFS = gridFS;
this.chunkSize = chunkSize;
this.id = BsonObjectId.GenerateNewId();
this.name = remoteFileName;
}