Пример #1
0
        } // End Sub Test

        public static MongoDB.Bson.ObjectId UploadFile(MongoGridFs gridFs, string fileName)
        {
            MongoDB.Bson.ObjectId id = MongoDB.Bson.ObjectId.Empty;
            // UploadFile
            using (System.IO.Stream file = System.IO.File.OpenRead(fileName))
            {
                id = gridFs.AddFile(file, fileName);
            } // End Using file

            return(id);
        } // End Sub UploadFile
Пример #2
0
        public static MongoDB.Bson.ObjectId UploadFile(MongoGridFs gridFs, string fileName)
        {
            MongoDB.Bson.ObjectId id = MongoDB.Bson.ObjectId.Empty;
            // UploadFile
            using (System.IO.Stream file = System.IO.File.OpenRead(fileName))
            {
                id = gridFs.AddFile(file, fileName);
            } // End Using file

            return id;
        }
Пример #3
0
        public bool Add(Song song)
        {
            MongoCollection songs = DB.GetCollection <Song>("Song");

            //var testFileName = "C:\\Users\\Matija\\Downloads\\System Of A Down - Chop Suey!.mp3";  //sta ce radimo s ovim?
            var gridFs = new MongoGridFs(dataBase);

            var id   = ObjectId.Empty;
            var file = song.File;

            id           = gridFs.AddFile(file, song.Name);
            song.songRef = id.ToString();     // ovo mora se postavi ovako manuelno jer se tu gore generise
            song.File    = null;
            song.Likes   = 0;

            return(songs.Insert <Song>(song, SafeMode.True).Ok);
        }