2016-10-08 2 views
0

Asp.net으로 작성된 백엔드 서버와 함께 cordova를 사용하는 크로스 플랫폼 모바일 앱에서 작업하고 있습니다. REST API 을 사용하여 애플리케이션에서 서버로 파일을 업로드하고 싶습니다. 메서드가 중단 점을 사용하여 호출되는지 확인하고 싶었습니다. 예외 메시지로 내 링크에 오류가 발생합니다. 업로드하지 않으며 중단 점이 시작되지 않습니다. 여기에 코드ngCordova를 사용하여 파일을 업로드 할 때 excetipn

[HttpPost] 
     [Route("Api/Token/test")] 
     public IHttpActionResult TestFile(HttpPostedFileBase file) { 
      if (file != null) 
      { 

      } 
      return Ok(); 
     }` 

콘솔의 출력 파일

var url = "http:/192.168.101.1:3000/api/token/test"; 
//File for Upload 
var targetPath = cordova.file.externalRootDirectory + "logo_radni.png"; 
// File name only 
var filename = targetPath.split("/").pop(); 
var options = { 
    fileKey: "file", 
    fileName: filename, 
    chunkedMode: false, 
    mimeType: "image/jpg", 
    params : {'directory':'upload', 'fileName':filename} 
}; 

$cordovaFileTransfer.upload(url, targetPath,options).then(function (result) { 
console.log("SUCCESS: " + JSON.stringify(result.response)); 
        }, function (err) { 
         console.log("ERROR: " + JSON.stringify(err)); 
        }, function (progress) { 
         // PROGRESS HANDLING GOES HERE 
        }); 

이 업로드이 내 코드입니다 {"code":3,"source":"file:///storage/emulated/0/logo_radni.png","target":"http:/192.168.101.1:3000/api/token/test","http_status":null,"body":null,"exception":"http:/192.168.101.1:3000/api/token/test"} (21:47:56:267)

이 내 config.xml 파일입니다

<access origin="*"/> 
    <allow-intent href="http://*/*"/> 
    <allow-intent href="https://*/*"/> 
    <allow-intent href="tel:*"/> 
    <allow-intent href="sms:*"/> 
    <allow-intent href="mailto:*"/> 
    <allow-intent href="geo:*"/> 
    <allow-navigation href="http://*/*" /> 
    <allow-navigation href="https://*/*" /> 
+0

'http : /192.168.101.1 : 3000' =>'http : //192.168.101.1 : 3000' 코드에 슬래시가 없습니다. – e666

답변

1

나는 슬래시가 누락되었다고 생각합니다. http:/192.168.101.1:3000 여기서는 http://192.168.101.1:3000이어야합니다.