Why some specific image file can not be uploaded

0

I need to upload client file to my server.

Here my client web application is build on Angular and using .net API I push image file to my server. Now the application working perfectly well, but one day my client found that the application doesn't able to upload 1 specific file. I tried it with my local system and all thing goes very well with the same code. But when I tried the same thing with published code, YES it won't work with that file.

After lots of research and code change I'm not upto my solution. I tried with the same file by edit that file and re-upload and it works good. But that's not the option at client end.

1.Below is my angular web application demo code which posts file to .net api method UploadFileMethod

let formData: FormData = new FormData();
let httpUploadRequest = this.apiservice.UploadFiles('api/UploadFileMethod', formData).subscribe(
data => {
    if (data.Status === 'Success') {
    }
},
err => {
    //COME HERE FROM API CALL FOR SOME SPECIFIC FILES
});

2.Below is my .net webapi demo function which accept file

[HttpPost]
public IHttpActionResult UploadFileMethod()
{
    var httpRequest = HttpContext.Current.Request;
    if (httpRequest.Files.Count > 0)
    {
        HttpPostedFile postedFile = httpRequest.Files[file];
        //SAVE FILE
    }
}

When I tried with log, I found that httpRequest.Files.Count return 0. The same code working perfectly for many other file.

Below is the error log

Error Message : An error occurred while communicating with the remote host. The error code is 0x80070001.
Error Details :    at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
   at System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(Byte[] buffer, Int32 offset, Int32 size)
   at System.Web.HttpRequest.GetEntireRawContent()
   at System.Web.HttpRequest.GetMultipartContent()
   at System.Web.HttpRequest.FillInFormCollection()
   at System.Web.HttpRequest.EnsureForm()
   at System.Web.HttpRequest.get_Form()
   at System.Web.HttpRequest.FillInParamsCollection()
   at System.Web.HttpRequest.GetParams()
   at MagnitudeGoldWebApp.Controllers.v1.CaptureController.UploadFileMethod()

The files I uploaded using this same functionality "good.jpg" uploaded successfully, meanwhile "bad.jpg" create the issue.

good.jpg

bad.jpg

c#
angular
asp.net-web-api
file-upload
asked on Stack Overflow Jul 11, 2018 by manishjain-kcspl • edited Jul 11, 2018 by manishjain-kcspl

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0