void LoadFile(string filePath) { var document = new ImageObject(); document.Data = File.ReadAllBytes(filePath); var fileName = Path.GetFileName(filePath); document.OriginalFileName = fileName; document.LoadHash(); var existing = Images.Find(x => x.DataHash == document.DataHash); if (existing.Any()) { Log.Debug("Already have: " + fileName); } else { Log.Debug("Inserting " + fileName + " " + document.Data.Length); Images.InsertOne(document); } }
public WebImage(ImageObject o) { this.Id = o.Id.ToString(); this.OriginalFileName = o.OriginalFileName; this.MimeType = MimeTypeMap.GetMimeType(Path.GetExtension(this.OriginalFileName)); }