ユーザーがzipファイルをアップロードできるローカルネットワークでサイトを実行しています。しかし、ローカル エリア ネットワーク (localhost ではなく) でテストを開始すると、ファイルは blob として表示されますか? 例: IIS Express が実行されているローカルホストで、example.zip をアップロードすると、アップロード フォルダーに example.zip として問題なく表示されます。別のマシンからアップロードしようとすると、example.zip が blob として表示されます。興味深いことに、ファイルの名前を example.zip に戻して正しい拡張子を指定すると、ファイルは完全に無傷であり、読み取ることができます。フォルダーのアクセス許可かもしれないと思ったので、アップロードフォルダーを全員から完全に制御してテストしましたが、まだ機能しません。これは、入ってくるファイルを保存する API コントローラーからのコードです。
public class UploadController : ApiController
{
// Enable both Get and Post so that our jquery call can send data, and get a status
[HttpGet]
[HttpPost]
public HttpResponseMessage Upload()
{
// Get a reference to the file that our jQuery sent. Even with multiple files, they will all be their own request and be the 0 index
HttpPostedFile file = HttpContext.Current.Request.Files[0];
// do something with the file in this space
if (File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/uploads/test/" + file.FileName)))
{
Stream input = file.InputStream;
FileStream output = new FileStream(HttpContext.Current.Server.MapPath("~/App_Data/uploads/test/" + file.FileName), FileMode.Append);
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, len);
}
input.Close();
output.Close();
}
else
{
file.SaveAs(HttpContext.Current.Server.MapPath("~/App_Data/uploads/test/" + file.FileName));
}
// end of file doing
// Now we need to wire up a response so that the calling script understands what happened
HttpContext.Current.Response.ContentType = "text/plain";
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
var result = new { name = file.FileName};
HttpContext.Current.Response.Write(serializer.Serialize(result));
HttpContext.Current.Response.StatusCode = 200;
// For compatibility with IE's "done" event we need to return a result as well as setting the context.response
return new HttpResponseMessage(HttpStatusCode.OK);
}
}
ファイルが blob として保存される理由はありますか? ありがとう!