मैं अपनी परियोजना में वेबपी के साथ फ़ाइल अपलोड का उपयोग करता हूं। मैं डाकिया के साथ परीक्षण कर रहा हूँ। हालांकि, Request.Content.IsMimeMultipartContent() हमेशा झूठी वापसी करता है।डाकिया में फ़ाइल अपलोड त्रुटि को कैसे हल करें?
डाकिया स्क्रीनशॉट:
FileUploadController कोड:
public async Task<HttpResponseMessage> UserImageUpload()
{
try
{
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
var userImageUploadPath = HttpContext.Current.Server.MapPath(CommonParameters.UserProfileImageServerPath);
var streamProvider = new CustomMultipartFormDataStreamProvider(userImageUploadPath);
await Request.Content.ReadAsMultipartAsync(streamProvider);
var files = new List<string>();
foreach (MultipartFileData file in streamProvider.FileData)
{
files.Add(Path.GetFileName(file.LocalFileName));
}
return Request.CreateResponse(HttpStatusCode.OK, files);
}
catch (Exception exception)
{
logger.ErrorFormat("An error occured in UserImageUpload() Method - Class:FileUploadController - Message:{0}", exception);
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
}
मैंने फिडलर के साथ फ़ाइल अपलोड करने का प्रयास किया। इसने काम कर दिया। –
एक ही चीज़ का अनुभव करना। क्या आपको समस्या मिल गई? – Alex