コード例 #1
0
 public override void RemoveOutput(UploadedFile file)
 {
     //MongoPolicy.Delete(file.ServerLocation);
     // If it's a valid upload
     if (!string.IsNullOrEmpty(file.ServerLocation) && MongoPolicy.Exist(file.ServerLocation))
     {
         MongoPolicy.Delete(file.ServerLocation);
     }
 }
コード例 #2
0
        public void should_add_file_and_delete()
        {
            var id = Guid.NewGuid().ToString();

            var repository = new MongoPolicy();
            var result     = repository.Add(file, id);

            Assert.IsTrue(repository.Exist(id));

            repository.Delete(result.fileName);
            Assert.IsFalse(repository.Exist(id));
        }
コード例 #3
0
        public void should_copy_to_localfile()
        {
            var id = Guid.NewGuid().ToString();

            var repository = new MongoPolicy();

            var result = repository.Add(file, id);

            repository.Copy(localfile, result.fileName);
            repository.Delete(result.fileName);

            Assert.IsTrue(File.Exists(localfile));
            File.Delete(localfile);
        }
コード例 #4
0
        public void should_add_stream_and_delete()
        {
            var id = Guid.NewGuid().ToString();

            var repository = new MongoPolicy();

            using (var stream = new FileStream(file, FileMode.Open))
            {
                string mimetype = MimeMapping.GetMimeMapping(file);
                var    result   = repository.AddStream(stream, mimetype, id);
                repository.Copy(localfile, result.fileName);
                repository.Delete(result.fileName);

                Assert.IsTrue(File.Exists(localfile));
                File.Delete(localfile);
            }
        }
コード例 #5
0
        public void should_copy_to_localstream()
        {
            string id = Guid.NewGuid().ToString();

            var repository = new MongoPolicy();

            repository.Add(file, id);
            byte[] bytes = repository.GetBytes(id);
            repository.Delete(id);

            using (var fs = new FileStream(localfile, FileMode.Create))
            {
                fs.Read(bytes, 0, bytes.Count());
            }

            Assert.IsTrue(File.Exists(localfile));
            File.Delete(localfile);
        }