Updating
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ public class DirectFileOperationsController : ControllerBase
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> WriteBinaryFile([FromBody] WriteFileRequest request)
|
||||
{
|
||||
return await HandleRequestResponse(request, FileOperationType.WriteFile, _writeFileService);
|
||||
return await HandleRequestResponse(request, FileOperationType.WriteBinaryFile, _writeFileService);
|
||||
}
|
||||
|
||||
[HttpPost("CreateDirectory")]
|
||||
|
||||
-10
@@ -243,16 +243,6 @@ public class FileOperationsController : ControllerBase
|
||||
return await HandleRequestResponse(request, FileOperationType.WriteFile, _writeFileDataService);
|
||||
}
|
||||
|
||||
// POST api/WriteBinaryFileData
|
||||
[HttpPost("WriteBinaryFileData")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> WriteBinaryFileData([FromBody] WriteFileRequest request)
|
||||
{
|
||||
return await HandleRequestResponse(request, FileOperationType.WriteFile, _writeFileDataService);
|
||||
}
|
||||
|
||||
[HttpPost("DeleteDirectory")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
|
||||
@@ -160,6 +160,7 @@ void AddServiceFactoryServices(IServiceCollection services)
|
||||
services.AddScoped<IFileActionService, ExtractIndexFileDataService>();
|
||||
services.AddScoped<IFileActionService, DeleteEmptyDirectoryService>();
|
||||
services.AddScoped<IFileActionService, ValidateFileSizeInRangeService>();
|
||||
services.AddScoped<IFileActionService, WriteBinaryFileService>();
|
||||
}
|
||||
|
||||
void AddFileActionServices(IServiceCollection services)
|
||||
|
||||
-7
@@ -44,13 +44,6 @@ namespace LCU.Api.Internal.FileOperations.Services.FileActionServices
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.Equals(request.Extension?.TrimStart('.'), "wav", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var fileBytes = Convert.FromBase64String(request.FileData);
|
||||
File.WriteAllBytes(request.FullFilePath, fileBytes);
|
||||
return;
|
||||
}
|
||||
|
||||
File.WriteAllText(request.FullFilePath, request.FileData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@@ -20,92 +20,96 @@
|
||||
"ServiceFactoryRegistrations": [
|
||||
{
|
||||
"ServiceInterfaceName": "IFileActionService",
|
||||
"ServiceRegistrations": [
|
||||
{
|
||||
"ServiceName": "MoveFileService",
|
||||
"ServiceId": "0"
|
||||
},
|
||||
{
|
||||
"ServiceName": "CopyFileService",
|
||||
"ServiceId": "1"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DeleteFileService",
|
||||
"ServiceId": "2"
|
||||
},
|
||||
{
|
||||
"ServiceName": "RenameFileService",
|
||||
"ServiceId": "3"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ZipDirectoryService",
|
||||
"ServiceId": "4"
|
||||
},
|
||||
{
|
||||
"ServiceName": "CreateDirectoryService",
|
||||
"ServiceId": "5"
|
||||
},
|
||||
{
|
||||
"ServiceName": "RenameDirectoryService",
|
||||
"ServiceId": "6"
|
||||
},
|
||||
{
|
||||
"ServiceName": "BulkOperationService`1",
|
||||
"ServiceId": "7"
|
||||
},
|
||||
{
|
||||
"ServiceName": "UnzipFileService",
|
||||
"ServiceId": "8"
|
||||
},
|
||||
{
|
||||
"ServiceName": "EncryptFileDataService",
|
||||
"ServiceId": "9"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DecryptFileDataService",
|
||||
"ServiceId": "10"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ModifyFileService",
|
||||
"ServiceId": "11"
|
||||
},
|
||||
{
|
||||
"ServiceName": "UnzipPasswordProtectedFileService",
|
||||
"ServiceId": "12"
|
||||
},
|
||||
{
|
||||
"ServiceName": "BatchPdfParserService",
|
||||
"ServiceId": "13"
|
||||
},
|
||||
{
|
||||
"ServiceName": "WriteFileService",
|
||||
"ServiceId": "14"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DeleteDirectoryService",
|
||||
"ServiceId": "15"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ValidateFileService",
|
||||
"ServiceId": "16"
|
||||
},
|
||||
{
|
||||
"ServiceName": "AppendFileService",
|
||||
"ServiceId": "17"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ExtractIndexFileDataService",
|
||||
"ServiceId": "18"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DeleteEmptyDirectoryService",
|
||||
"ServiceId": "19"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ValidateFileSizeInRangeService",
|
||||
"ServiceId": "20"
|
||||
}
|
||||
]
|
||||
"ServiceRegistrations": [
|
||||
{
|
||||
"ServiceName": "MoveFileService",
|
||||
"ServiceId": "0"
|
||||
},
|
||||
{
|
||||
"ServiceName": "CopyFileService",
|
||||
"ServiceId": "1"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DeleteFileService",
|
||||
"ServiceId": "2"
|
||||
},
|
||||
{
|
||||
"ServiceName": "RenameFileService",
|
||||
"ServiceId": "3"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ZipDirectoryService",
|
||||
"ServiceId": "4"
|
||||
},
|
||||
{
|
||||
"ServiceName": "CreateDirectoryService",
|
||||
"ServiceId": "5"
|
||||
},
|
||||
{
|
||||
"ServiceName": "RenameDirectoryService",
|
||||
"ServiceId": "6"
|
||||
},
|
||||
{
|
||||
"ServiceName": "BulkOperationService`1",
|
||||
"ServiceId": "7"
|
||||
},
|
||||
{
|
||||
"ServiceName": "UnzipFileService",
|
||||
"ServiceId": "8"
|
||||
},
|
||||
{
|
||||
"ServiceName": "EncryptFileDataService",
|
||||
"ServiceId": "9"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DecryptFileDataService",
|
||||
"ServiceId": "10"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ModifyFileService",
|
||||
"ServiceId": "11"
|
||||
},
|
||||
{
|
||||
"ServiceName": "UnzipPasswordProtectedFileService",
|
||||
"ServiceId": "12"
|
||||
},
|
||||
{
|
||||
"ServiceName": "BatchPdfParserService",
|
||||
"ServiceId": "13"
|
||||
},
|
||||
{
|
||||
"ServiceName": "WriteFileService",
|
||||
"ServiceId": "14"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DeleteDirectoryService",
|
||||
"ServiceId": "15"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ValidateFileService",
|
||||
"ServiceId": "16"
|
||||
},
|
||||
{
|
||||
"ServiceName": "AppendFileService",
|
||||
"ServiceId": "17"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ExtractIndexFileDataService",
|
||||
"ServiceId": "18"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DeleteEmptyDirectoryService",
|
||||
"ServiceId": "19"
|
||||
},
|
||||
{
|
||||
"ServiceName": "ValidateFileSizeInRangeService",
|
||||
"ServiceId": "20"
|
||||
},
|
||||
{
|
||||
"ServiceName": "WriteFileService",
|
||||
"ServiceId": "21"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
-21
@@ -75,27 +75,6 @@ public class FileOperationsControllerTest
|
||||
_mockDirectFileService.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WriteBinaryFileDataPost_OK()
|
||||
{
|
||||
var request = new WriteFileRequest
|
||||
{
|
||||
FileData = Convert.ToBase64String(new byte[] { 0x52, 0x49, 0x46, 0x46 }),
|
||||
DestinationPath = "SomePath",
|
||||
Extension = ".wav",
|
||||
FileName = "FileName"
|
||||
};
|
||||
|
||||
var validRequestResponse = new RequestResponse() { MessageStack = new List<string>(), IsSuccessful = true };
|
||||
_mockWriteFileDataService.Setup(service => service.PreQueueValidation(It.IsAny<WriteFileRequest>())).Returns(validRequestResponse);
|
||||
|
||||
var result = await _controller.WriteBinaryFileData(request);
|
||||
var okResult = result as OkResult;
|
||||
|
||||
Assert.NotNull(okResult);
|
||||
Assert.Equal(200, okResult.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFile_OK()
|
||||
{
|
||||
|
||||
+2
-1
@@ -21,5 +21,6 @@ public enum FileOperationType
|
||||
AppendFile = 17,
|
||||
ExtractIndexFileData = 18,
|
||||
DeleteEmptyDirectory = 19,
|
||||
ValidateFileSizeInRange = 20
|
||||
ValidateFileSizeInRange = 20,
|
||||
WriteBinaryFile = 21
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user