Unity3d : 500 внутренняя ошибка сервера : при загрузке файла с помощью WWW и wwwform
I am trying to upload a file to the server using www and wwwForm from the client Side using this code :
WWW localFile = new WWW("file://"+ FilePath); yield return localFile; WWWForm postForm = new WWWForm(); postForm.AddField("frameCount", Time.frameCount.ToString()); postForm.AddBinaryData("file", localFile.bytes, "filename.obj"); WWW upload = new WWW(uploadUrl, postForm); yield return upload; if (upload.error == null) { Debug.Log(upload.text); } else { Debug.Log("Error during upload: " + upload.error); }
Calling the ASP.net Service Upload File :
public async Task<HttpResponseMessage> UploadFileAsync() { try { var provider = new MultipartMemoryStreamProvider(); await Request.Content.ReadAsMultipartAsync(provider); foreach (var file in provider.Contents) { var dataStream = await file.ReadAsStreamAsync(); // use the data stream to persist the data to the server (file system etc) Stream fileStream = File.Create("D:\\filename.obj"); dataStream.CopyTo(fileStream); fileStream.Close(); dataStream.Close(); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent("Successful upload", Encoding.UTF8, "text/plain"); response.Content.Headers.ContentType = new MediaTypeWithQualityHeaderValue(@"text/html"); return response; } return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No File Uploaded"); } catch (Exception e) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message); } }
and I am getting ( 500 Internal Server Error)? the service was running Perfectly, but something wrong Happen, I get 500 Internal Server Error So what is the Wrong with That? Thanks in Advance
Что я уже пробовал:
Сервис работал отлично, я попытался увеличить максимальный размер файла ,
кроме того увеличение длины запроса не решило проблему