diff --git a/src/ChunkedFileUpload.cs b/src/ChunkedFileUpload.cs index 2cb62d5..6882a10 100644 --- a/src/ChunkedFileUpload.cs +++ b/src/ChunkedFileUpload.cs @@ -118,7 +118,7 @@ internal void Save( { using (Stream stream = new FileStream(chunkFileName, FileMode.Create)) { - inputStream.CopyTo(stream); //, _chunkUploadParameter.CurrentChunkSize); + inputStream.CopyTo(stream); } } catch (Exception exception) diff --git a/src/ChunkedFileUploadHandler.cs b/src/ChunkedFileUploadHandler.cs index 2b7241d..f16efa7 100644 --- a/src/ChunkedFileUploadHandler.cs +++ b/src/ChunkedFileUploadHandler.cs @@ -130,16 +130,23 @@ private void CheckIfChunkExistAndIsComplete( context.Response.StatusCode = fileManager.Exists() ? 200 : 204; } - private void HandleUploadedChunk(HttpContext context, ChunkUploadParameter chunkUploadParameter) + private void HandleUploadedChunk( + HttpContext context, + ChunkUploadParameter chunkUploadParameter) { var fileManager = new FileChunk(UploadBasePath, chunkUploadParameter); + if (context.Request.Files.Count == 0) + { + context.Response.StatusCode = 400; + return; + } + fileManager.Save(context.Request.Files[0].InputStream); if (fileManager.CheckIfAllChunksUploaded() && fileManager.MergeAllChunks(TargetPath)) - { OnUploadSucceeded(chunkUploadParameter); - } + context.Response.StatusCode = 201; }