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());
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        protected override ImportFile Transform(ImportFile file)
        {
            var path = Path.Combine(Path.GetDirectoryName(file.FilePath), "underscore", file.Name);

            return(ImportFile.Create(path, file.Content.Replace(" ", "_")));
        }