public IHttpActionResult Post(string name, string content) { if (string.IsNullOrEmpty(name)) { return(Error("Invalid file name")); } if (string.IsNullOrEmpty(content)) { return(Error("Invalid file content")); } try { var directory = _configuration.GetConfigurationValue(ConfigurationKeys.ImportDirectory, ""); if (string.IsNullOrEmpty(directory)) { return(InternalServerError("Import directory not set")); } var file = ImportFile.Create(Path.Combine(directory, name), content); file.Save(); } catch (Exception e) { _logger.Error(e.Message); return(InternalServerError("File not create")); } return(Ok()); }
protected override ImportFile Transform(ImportFile file) { var path = Path.Combine(Path.GetDirectoryName(file.FilePath), "uppercase_name", file.Name.ToUpperInvariant()); return(ImportFile.Create(path, file.Content)); }
protected override ImportFile Transform(ImportFile file) { var path = Path.Combine(Path.GetDirectoryName(file.FilePath), "underscore", file.Name); return(ImportFile.Create(path, file.Content.Replace(" ", "_"))); }