このチュートリアルに従って、ファイル転送用の iPhone クライアント側を作成しました。アップロードするファイルを選択できましたが、サーバーにアップロードすると次のようなエラーが発生します。
2013-03-01 19:38:35.841 StampedeTest[1687:c07] FileTransferError {
code = 3;
"http_status" = 405;
source = "file://localhost/Users/davidroper/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/5C506A40-959F-4A15-8D01-B3343EDB3257/tmp/cdv_photo_004.jpg";
target = "http://******.azurewebsites.net/api/FileUploadTest";
}
アップロード用のクライアント側コード
function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://*****.azurewebsites.net/api/FileUploadTest", win, fail, options);
}
サーバー側コード
public class FileUploadTestController : ApiController
{
[WebMethod]
public string Getupload()
{
if (HttpContext.Current.Request.Files["file"] != null)
{
HttpPostedFile file = HttpContext.Current.Request.Files["file"];
string targetFilePath = "http://stampedemvc.azurewebsites.net/Content/img/" + file.FileName;
file.SaveAs(targetFilePath);
return file.FileName.ToString();
}
else {
return "Error";
}
}
}
どうすればこれを機能させることができますか?
ありがとう。