2014-12-22 122 views
0

我有這段代碼,但是當完成上傳時我得到了header 400錯誤,並且我不知道發生了什麼,我有這個信息「HTTP 400 [application/json] Error。一個詳細描述錯誤的JSON對象。 「我改變參數,但開不工作,有人知道發生什麼事:將視頻上傳到wistia

function uploadFile(videoURI){ 
    var options = new FileUploadOptions(); 
    options.fileKey="file"; 
    options.fileName = videoURI.substr(videoURI.lastIndexOf('/')+1); 
    options.mimeType="video/mp4"; 
    options.chunkedMode = true; 

    var params = { 
    'access_token' : 'c7a9ef90684aa23472a9a3cfb01b35f4f55f6bf5cc392dbc9e01db5e8285f45a' 
    }; 

    options.params = params; 

    var headers = {'headerParam':'headerValue'}; 
    options.headers = headers; 

    var ft = new FileTransfer(); 
    ft.upload(videoURI, encodeURI("https://upload.wistia.com"), win, fail, options); 
} 

我得到這個在我的JSON:

response headers: {null=[HTTP/1.1 400 Bad Request], Content-Length=[181], Content-Type=[text/html], 
Date=[Mon, 22 Dec 2014 00:40:54 GMT], OkHttp-Received-Millis=[1419208903245], OkHttp-Response- 
Source=[NETWORK 400], OkHttp-Selected-Transport=[http/1.1], OkHttp-Sent-Millis=[1419208853743], 
Server=[nginx/1.4.6 (Ubuntu)], X-Served-By=[bakery-breadroute-sourdough,bakery-prime-professorx]} 

這就是結果:

12-21 19:04:45.613: D/FileTransfer(28193): upload /storage/extSdCard/DCIM/Camera/20141221_165353.mp4 to https://upload.wistia.com 
12-21 19:04:45.613: D/FileTransfer(28193): fileKey: file 
12-21 19:04:45.613: D/FileTransfer(28193): fileName: 20141221_165353.mp4 
12-21 19:04:45.613: D/FileTransfer(28193): mimeType: video/mp4 
12-21 19:04:45.613: D/FileTransfer(28193): params: {"access_token":"c7a9ef90684aa23472a9a3cfb01b35f4f55f6bf5cc392dbc9e01db5e8285f45a"} 
12-21 19:04:45.613: D/FileTransfer(28193): trustEveryone: false 
12-21 19:04:45.613: D/FileTransfer(28193): chunkedMode: true 
12-21 19:04:45.613: D/FileTransfer(28193): headers: {"headerParam":"headerValue"} 
12-21 19:04:45.613: D/FileTransfer(28193): objectId: 2 
12-21 19:04:45.613: D/FileTransfer(28193): httpMethod: POST 
12-21 19:04:45.663: V/webview(28193): singleCursorHandlerTouchEvent -getEditableSupport FASLE 
12-21 19:04:45.713: D/FileTransfer(28193): Content Length: 4313617 
12-21 19:04:45.794: D/webview(28193): blockWebkitViewMessage= false 
12-21 19:04:46.264: D/dalvikvm(28193): GC_CONCURRENT freed 141K, 16% free 9940K/11783K, paused 19ms+19ms, total 77ms 
12-21 19:04:46.444: D/FileTransfer(28193): Uploaded 114931 of 4313617 bytes 
12-21 19:04:46.474: D/FileTransfer(28193): Uploaded 229619 of 4313617 bytes 
12-21 19:04:46.504: D/FileTransfer(28193): Uploaded 344307 of 4313617 bytes 
12-21 19:04:48.206: D/FileTransfer(28193): Uploaded 458995 of 4313617 bytes 
12-21 19:04:49.898: D/FileTransfer(28193): Uploaded 573683 of 4313617 bytes 
12-21 19:04:51.579: D/FileTransfer(28193): Uploaded 688371 of 4313617 bytes 
12-21 19:04:53.901: D/FileTransfer(28193): Uploaded 803059 of 4313617 bytes 
12-21 19:04:53.971: D/FileTransfer(28193): Uploaded 917747 of 4313617 bytes 
12-21 19:04:54.022: D/dalvikvm(28193): GC_CONCURRENT freed 659K, 18% free 9666K/11783K, paused 12ms+2ms, total 41ms 
12-21 19:04:55.093: D/FileTransfer(28193): Uploaded 1032435 of 4313617 bytes 
12-21 19:04:57.895: D/FileTransfer(28193): Uploaded 1147123 of 4313617 bytes 
12-21 19:04:57.925: D/FileTransfer(28193): Uploaded 1261811 of 4313617 bytes 
12-21 19:04:59.597: D/FileTransfer(28193): Uploaded 1376499 of 4313617 bytes 
12-21 19:05:01.300: D/FileTransfer(28193): Uploaded 1491187 of 4313617 bytes 
12-21 19:05:02.982: D/FileTransfer(28193): Uploaded 1605875 of 4313617 bytes 
12-21 19:05:05.284: D/FileTransfer(28193): Uploaded 1720563 of 4313617 bytes 
12-21 19:05:05.344: D/FileTransfer(28193): Uploaded 1835251 of 4313617 bytes 
12-21 19:05:06.655: D/FileTransfer(28193): Uploaded 1949939 of 4313617 bytes 
12-21 19:05:08.377: D/FileTransfer(28193): Uploaded 2064627 of 4313617 bytes 
12-21 19:05:08.427: D/dalvikvm(28193): GC_CONCURRENT freed 405K, 18% free 9665K/11783K, paused 12ms+3ms, total 46ms 
12-21 19:05:10.209: D/FileTransfer(28193): Uploaded 2179315 of 4313617 bytes 
12-21 19:05:11.890: D/FileTransfer(28193): Uploaded 2294003 of 4313617 bytes 
12-21 19:05:11.930: D/FileTransfer(28193): Uploaded 2408691 of 4313617 bytes 
12-21 19:05:13.642: D/FileTransfer(28193): Uploaded 2523379 of 4313617 bytes 
12-21 19:05:15.344: D/FileTransfer(28193): Uploaded 2638067 of 4313617 bytes 
12-21 19:05:17.766: D/FileTransfer(28193): Uploaded 2752755 of 4313617 bytes 
12-21 19:05:18.707: D/FileTransfer(28193): Uploaded 2867443 of 4313617 bytes 
12-21 19:05:20.419: D/FileTransfer(28193): Uploaded 2982131 of 4313617 bytes 
12-21 19:05:20.459: D/FileTransfer(28193): Uploaded 3096819 of 4313617 bytes 
12-21 19:05:22.351: D/FileTransfer(28193): Uploaded 3211507 of 4313617 bytes 
12-21 19:05:23.842: D/FileTransfer(28193): Uploaded 3326195 of 4313617 bytes 
12-21 19:05:23.852: D/dalvikvm(28193): GC_CONCURRENT freed 403K, 18% free 9667K/11783K, paused 12ms+3ms, total 49ms 
12-21 19:05:25.574: D/FileTransfer(28193): Uploaded 3440883 of 4313617 bytes 
12-21 19:05:27.255: D/FileTransfer(28193): Uploaded 3555571 of 4313617 bytes 
12-21 19:05:28.957: D/FileTransfer(28193): Uploaded 3670259 of 4313617 bytes 
12-21 19:05:30.939: D/FileTransfer(28193): Uploaded 3784947 of 4313617 bytes 
12-21 19:05:30.979: D/FileTransfer(28193): Uploaded 3899635 of 4313617 bytes 
12-21 19:05:32.681: D/FileTransfer(28193): Uploaded 4014323 of 4313617 bytes 
12-21 19:05:34.923: D/FileTransfer(28193): Uploaded 4129011 of 4313617 bytes 
12-21 19:05:36.184: D/FileTransfer(28193): Uploaded 4243699 of 4313617 bytes 
12-21 19:05:36.204: D/FileTransfer(28193): Sent 4313617 of 4313617 
12-21 19:05:36.214: D/FileTransfer(28193): response code: 400 
12-21 19:05:36.214: D/FileTransfer(28193): response headers: {null=[HTTP/1.1 400 Bad Request], Content-Length=[181], Content-Type=[text/html], Date=[Mon, 22 Dec 2014 01:04:47 GMT], OkHttp-Received-Millis=[1419210336214], OkHttp-Response-Source=[NETWORK 400], OkHttp-Selected-Transport=[http/1.1], OkHttp-Sent-Millis=[1419210286427], Server=[nginx/1.4.6 (Ubuntu)], X-Served-By=[bakery-breadroute-multigrain,bakery-prime-mystique]} 
12-21 19:05:36.254: E/FileTransfer(28193): {"target":"https:\/\/upload.wistia.com","http_status":400,"body":"<html>\n<head><title>400 Bad Request<\/title><\/head>\n<body bgcolor=\"white\">\n<center><h1>400 Bad Request<\/h1><\/center>\n<hr><center>nginx\/1.4.6 (Ubuntu)<\/center>\n<\/body>\n<\/html>","code":1,"source":"\/storage\/extSdCard\/DCIM\/Camera\/20141221_165353.mp4","exception":"https:\/\/upload.wistia.com"} 
12-21 19:05:36.254: E/FileTransfer(28193): java.io.FileNotFoundException: https://upload.wistia.com 
12-21 19:05:36.254: E/FileTransfer(28193): at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:187) 
12-21 19:05:36.254: E/FileTransfer(28193): at com.squareup.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:247) 
12-21 19:05:36.254: E/FileTransfer(28193): at org.apache.cordova.filetransfer.FileTransfer.getInputStream(FileTransfer.java:527) 
12-21 19:05:36.254: E/FileTransfer(28193): at org.apache.cordova.filetransfer.FileTransfer.access$400(FileTransfer.java:69) 
12-21 19:05:36.254: E/FileTransfer(28193): at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:446) 
12-21 19:05:36.254: E/FileTransfer(28193): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 
12-21 19:05:36.254: E/FileTransfer(28193): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 
12-21 19:05:36.254: E/FileTransfer(28193): at java.lang.Thread.run(Thread.java:856) 
12-21 19:05:36.274: D/dalvikvm(28193): GC_CONCURRENT freed 396K, 18% free 9675K/11783K, paused 12ms+13ms, total 54ms 
12-21 19:05:36.414: W/ResourceType(28193): Failure getting entry for 0x010802c8 (t=7 e=712) in package 0 (error -75) 
12-21 19:05:41.800: D/CordovaLog(28193): file:///android_asset/www/js/video.js: Line 111 : upload error source /storage/extSdCard/DCIM/Camera/20141221_165353.mp4 
12-21 19:05:41.800: I/Web Console(28193): upload error source /storage/extSdCard/DCIM/Camera/20141221_165353.mp4:111 
12-21 19:05:41.810: D/CordovaLog(28193): file:///android_asset/www/js/video.js: Line 112 : upload error target https://upload.wistia.com 
12-21 19:05:41.810: I/Web Console(28193): upload error target https://upload.wistia.com:112 

回答

0

我改變一些代碼,這是我做的,它的工作原理:

function uploadFile(videoURI){ 
var options = new FileUploadOptions(); 
options.fileKey="videoPath"; 
options.fileName = videoURI.substr(videoURI.lastIndexOf('/')+1); 
options.mimeType="video/mp4"; 
options.chunkedMode = false; 

var params = { 
    "access_token": "c7a9ef90684aa23472a9a3cfb01b35f4f55f6bf5cc392dbc9e01db5e8285f45a", 
    "file": videoURI 
}; 

options.params = params; 

var ft = new FileTransfer(); 
ft.upload(videoURI, encodeURI("https://upload.wistia.com/"), win, fail, options); 
}