DownloadListener 을 사용해서 파일을 다운로드 받으려고 하는데.
웹뷰에서 다운로드를 누르면 php소스로 이동합니다. 거기서 이제 파일다운로드를 시키는데
php의 http://php.net/manual/en/function.fpassthru.php 이부분을 이용해서 다운로드 시키고 있는 것 같습니다.
웹은 정상적으로 되는데
앱에서는 파일명이나 헤더정보는 잘 날라오는데
파일이 다운로드 받아지질 않습니다 .
파일을 50바이트 다운받고 완료라고 하는걸 보아하니 다운로드 받을 파일이 없는것같은데...
카카오톡이나 네이버 내장브라우저에서는 정상적으로 다운로드 되는데
왜 앱에서는 안되는지 모르겠습니다.
http://dl.google.com/android/adt/adt-bundle-windows-x86-20131030.zip
근데 다운로드 소스 자체는 문제가 없다고 판단한게 저 url은 정상적으로 다운로드 받아집니다.
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setMimeType(mimetype);
request.addRequestHeader("User-Agent", userAgent);
request.setDescription("Downloading file");
request.setTitle(URLUtil.guessFileName(url,contentDisposition,mimetype));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url,contentDisposition,mimetype));
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Toast.makeText(getApplicationContext(), "Downloading File", Toast.LENGTH_LONG).show();
header('Content-Type: ' . $this->mimetype);
header('Content-Disposition: attachment; filename="' . $this->dl_filename . '"');
header("Content-Transfer-Encoding: binary");
header('Accept-Ranges: bytes');
/* The three lines below basically make the
download non-cacheable */
header("Cache-control: private");
header('Pragma: private');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// multipart-download and download resuming support
if(isset($_SERVER['HTTP_RANGE']) && !$this->force_single){
list($a, $range) = explode("=", $_SERVER['HTTP_RANGE'], 2);
list($range) = explode(",", $range, 2);
list($range, $range_end) = explode("-", $range);
$range = intval($range);
if(!$range_end){
$range_end = $size - 1;
}else{
$range_end = intval($range_end);
}
$new_length = $range_end - $range + 1;
header('HTTP/1.1 206 Partial Content');
header('Content-Length: ' . $new_length);
header('Content-Range: bytes ' . $range . '-' . $range_end . '/' . $size);
//set the offset range
$this->mt_range = $range;
}else{
$new_length = $size;
header("Content-Length: " . $size);
}