1- using Amazon . Runtime . Internal ;
1+ using Amazon . Runtime . Internal ;
22using ManagedCode . Communication ;
33using ManagedCode . Storage . Core ;
44using ManagedCode . Storage . Core . Models ;
99namespace ManagedCode . Storage . IntegrationTests . TestApp . Controllers . Base ;
1010
1111[ ApiController ]
12- public abstract class BaseTestController < TStorage > : BaseController
12+ public abstract class BaseTestController < TStorage > : ControllerBase
1313 where TStorage : IStorage
1414{
15- private readonly ResponseContext _responseData ;
16- private readonly int chunkSize ;
17- private readonly string tempFolder ;
15+ protected readonly IStorage Storage ;
16+ protected readonly ResponseContext ResponseData ;
17+ protected readonly int ChunkSize ;
1818
19- protected BaseTestController ( TStorage storage ) : base ( storage )
19+ protected BaseTestController ( TStorage storage )
2020 {
21- _responseData = new ResponseContext ( ) ;
22- chunkSize = 100000000 ;
23- tempFolder = "C: \\ Users \\ sasha" ;
21+ Storage = storage ;
22+ ResponseData = new ResponseContext ( ) ;
23+ ChunkSize = 100000000 ;
2424 }
2525
2626 [ HttpPost ( "upload" ) ]
@@ -55,11 +55,11 @@ public async Task<IActionResult> UploadChunks(CancellationToken cancellationToke
5555 try
5656 {
5757 var chunkNumber = Guid . NewGuid ( ) . ToString ( ) ;
58- string newpath = Path . Combine ( tempFolder + "/TEMP" , "file" + chunkNumber ) ;
58+ string newpath = Path . Combine ( Path . GetTempPath ( ) , "file" + chunkNumber ) ;
5959
6060 await using ( FileStream fs = System . IO . File . Create ( newpath ) )
6161 {
62- byte [ ] bytes = new byte [ chunkSize ] ;
62+ byte [ ] bytes = new byte [ ChunkSize ] ;
6363 int bytesRead = 0 ;
6464 while ( ( bytesRead = await Request . Body . ReadAsync ( bytes , 0 , bytes . Length , cancellationToken ) ) > 0 )
6565 {
@@ -73,15 +73,15 @@ public async Task<IActionResult> UploadChunks(CancellationToken cancellationToke
7373 // _responseData.IsSuccess = false;
7474 }
7575
76- return Ok ( _responseData ) ;
76+ return Ok ( ResponseData ) ;
7777 }
7878
7979 [ HttpPost ( "upload-chunks/complete" ) ]
8080 public async Task < Result > UploadComplete ( [ FromBody ] string fileName )
8181 {
8282 try
8383 {
84- string tempPath = tempFolder + "/TEMP" ;
84+ string tempPath = Path . GetTempPath ( ) ;
8585 string newPath = Path . Combine ( tempPath , fileName ) ;
8686 // string[] filePaths = Directory.GetFiles(tempPath).Where(p => p.Contains(fileName))
8787 // .OrderBy(p => Int32.Parse(p.Replace(fileName, "$").Split('$')[1])).ToArray();
@@ -91,7 +91,7 @@ public async Task<Result> UploadComplete([FromBody] string fileName)
9191 MergeChunks ( newPath , filePath ) ;
9292 }
9393
94- System . IO . File . Move ( Path . Combine ( tempPath , fileName ) , Path . Combine ( tempFolder , fileName ) ) ;
94+ System . IO . File . Move ( Path . Combine ( tempPath , fileName ) , Path . Combine ( tempPath , fileName ) ) ;
9595 }
9696 catch ( Exception ex )
9797 {
0 commit comments