Skip to content

Instantly share code, notes, and snippets.

@SergXIIIth
Created June 2, 2011 10:39
Show Gist options
  • Save SergXIIIth/1004230 to your computer and use it in GitHub Desktop.
Save SergXIIIth/1004230 to your computer and use it in GitHub Desktop.
Mongo gridfg upload test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using MongoDB.Driver;
using System.Web.Mvc;
using System.IO;
using MongoDB.Driver.GridFS;
namespace Tests.Unit
{
[TestFixture]
public class MongoTest
{
[Test]
public void upload_in_gridFS_file_more_50mb()
{
var server = MongoServer.Create("mongodb://localhost:27017/HYPOXI");
var fs = server.GetDatabase("HYPOXI").GridFS;
// upload 100mb file few times
for (var i = 1; i <= 10; i++) {
"{0} ,".debug_w(i);
var content_type = "application/octetstream";
var file_name = "bigfile.exe";
fs.Delete(file_name);
using (var file_stream = File.OpenRead(file_name)) {
fs.Upload(file_stream, file_name, new MongoGridFSCreateOptions { ContentType = content_type });
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment