Advertisement

.net core 3.1 中 MongoDB GridFS 操作

阅读量:

存储桶操作实例

复制代码
    private static readonly MongoClient client = new MongoClient("mongodb://admin:222222@127.0.0.1:27017");
    private static readonly string dbName = "test";
    private static readonly IMongoDatabase database = client.GetDatabase(dbName);
    
    /// <summary>
    /// 存储桶操作实例
    /// </summary>
    private static readonly IGridFSBucket bucket = new GridFSBucket(database, new GridFSBucketOptions
    {
    BucketName = "videos",
    ChunkSizeBytes = 1048576, // 1MB
    WriteConcern = WriteConcern.WMajority,
    ReadPreference = ReadPreference.Secondary
    });
    
    

全部评论 (0)

还没有任何评论哟~