public string SaveFile(MeekFile file) { var parent = DataFile.Element("Meek"); var fileKey = Guid.NewGuid().ToString(); var newElement = new XElement("file"); newElement.Add(new XAttribute("fileName", fileKey)); newElement.Add(new XAttribute("originalFileName", file.FileName)); newElement.Add(new XAttribute("contentType", file.ContentType)); parent.Add(newElement); var stream = File.CreateText(Path.Combine(_baseDir, fileKey)); var binaryWriter = new BinaryWriter(stream.BaseStream); binaryWriter.Write(file.Contents, 0, file.Contents.Length); stream.Close(); DataFile = parent.Document; if (FileChanged != null) { FileChanged(this, new ResourceChangedArgs { Path = fileKey }); } return(fileKey); }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); Files.Add(fileId, file); return(fileId); }
public string SaveFile(MeekFile file) { string fileId; using (var conn = OpenConnection()) { fileId = Guid.NewGuid().ToString(); var command = _factory.CreateCommand(); command.Connection = conn; command.CommandText = "INSERT INTO MeekFile (Id, FileName, ContentType, Data) Values (@Id, @FileName, @ContentType, @Data)";; AddParam(command, SqlDbType.NVarChar, fileId, "Id"); AddParam(command, SqlDbType.NVarChar, file.FileName, "FileName"); AddParam(command, SqlDbType.NVarChar, file.ContentType, "ContentType"); AddParam(command, SqlDbType.Image, file.Contents, "Data"); command.ExecuteNonQuery(); } if (FileChanged != null) { FileChanged(this, new ResourceChangedArgs { Path = fileId }); } return(fileId); }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); //enforce keys to lower for querying Files.Save(new { Id = fileId.ToLower(), file.FileName, file.ContentType, file.Contents }); return(fileId); }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); Files.Add(fileId, file); if (FileChanged != null) { FileChanged(this, new ResourceChangedArgs { Path = fileId }); } return(fileId); }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); //enforce keys to lower for querying Files.Save(new { Id = fileId.ToLower(), file.FileName, file.ContentType, file.Contents }); if (FileChanged != null) { FileChanged(this, new ResourceChangedArgs { Path = fileId }); } return(fileId); }
public string SaveFile(MeekFile file) { using (var conn = OpenConnection()) { var fileId = Guid.NewGuid().ToString(); var command = _factory.CreateCommand(); command.Connection = conn; command.CommandText = "INSERT INTO MeekFile (Id, FileName, ContentType, Data) Values (@Id, @FileName, @ContentType, @Data)";; AddParam(command, SqlDbType.NVarChar, fileId, "Id"); AddParam(command, SqlDbType.NVarChar, file.FileName, "FileName"); AddParam(command, SqlDbType.NVarChar, file.ContentType, "ContentType"); AddParam(command, SqlDbType.Image, file.Contents, "Data"); command.ExecuteNonQuery(); return(fileId); } }
public string SaveFile(MeekFile file) { using (var conn = OpenConnection()) { var fileId = Guid.NewGuid().ToString(); var command = _factory.CreateCommand(); command.Connection = conn; command.CommandText = "INSERT INTO MeekFile (Id, FileName, ContentType, Data) Values (@Id, @FileName, @ContentType, @Data)"; ; AddParam(command, SqlDbType.NVarChar, fileId, "Id"); AddParam(command, SqlDbType.NVarChar, file.FileName, "FileName"); AddParam(command, SqlDbType.NVarChar, file.ContentType, "ContentType"); AddParam(command, SqlDbType.Image, file.Contents, "Data"); command.ExecuteNonQuery(); return fileId; } }
public string SaveFile(MeekFile file) { var parent = DataFile.Element("Meek"); var fileKey = Guid.NewGuid().ToString(); var newElement = new XElement("file"); newElement.Add(new XAttribute("fileName", fileKey)); newElement.Add(new XAttribute("originalFileName", file.FileName)); newElement.Add(new XAttribute("contentType", file.ContentType)); parent.Add(newElement); var stream = File.CreateText(Path.Combine(_baseDir,fileKey)); var binaryWriter = new BinaryWriter(stream.BaseStream); binaryWriter.Write(file.Contents, 0, file.Contents.Length); stream.Close(); DataFile = parent.Document; return fileKey; }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); Files.Add(fileId, file); if (FileChanged != null) FileChanged(this, new ResourceChangedArgs {Path = fileId}); return fileId; }
public string SaveFile(MeekFile file) { throw new NotImplementedException(); }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); Files.Add(fileId, file); return fileId; }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); //enforce keys to lower for querying Files.Save(new { Id = fileId.ToLower(), file.FileName, file.ContentType, file.Contents}); return fileId; }
public string SaveFile(MeekFile file) { var fileId = Guid.NewGuid().ToString(); //enforce keys to lower for querying Files.Save(new { Id = fileId.ToLower(), file.FileName, file.ContentType, file.Contents}); if (FileChanged != null) FileChanged(this, new ResourceChangedArgs { Path = fileId }); return fileId; }
public string SaveFile(MeekFile file) { string fileId; using (var conn = OpenConnection()) { fileId = Guid.NewGuid().ToString(); var command = _factory.CreateCommand(); command.Connection = conn; command.CommandText = "INSERT INTO MeekFile (Id, FileName, ContentType, Data) Values (@Id, @FileName, @ContentType, @Data)"; ; AddParam(command, SqlDbType.NVarChar, fileId, "Id"); AddParam(command, SqlDbType.NVarChar, file.FileName, "FileName"); AddParam(command, SqlDbType.NVarChar, file.ContentType, "ContentType"); AddParam(command, SqlDbType.Image, file.Contents, "Data"); command.ExecuteNonQuery(); } if (FileChanged != null) FileChanged(this, new ResourceChangedArgs { Path = fileId }); return fileId; }