잠시 메모 해둡니다. 테스트 해보지는 않았습니다.

출처는 다음과 같습니다. : http://blog.naver.com/lkssky2002/120135593219


ASP페이지에서 스마트폰(ANDROID) 다운로드 처리

 

- 문제당면 환경 및 상황

 

 + 첨부파일이 보여지는 VIEW 페이지 : CharSet = utf-8

 + 첨부파일을 다운로드 하는 서블릿 페이지는 : 파일 타입 = ANSI

 + VIEW 페이지에서 파일명 파라미터로 보낼때 <%= escape(fileName) %> 처리해서 보냄

 

- 기존 실행결과

 

 + 익스플로러, 파이어폭스에서 한글명 파일다운로드 정상

 + 아이폰 다운로드는 되나 한글파일명 깨짐

 + 안드로이드 폰 다운로드 안됨.

 

--------------------------------------------------

 

- 처리방안

 

 + 다운로드 서블릿 페이지 타입을 ANSI -> UTF-8로 변경

 + 다운로드 서블릿 페이지 상단에 언어처리(utf-8)

    <%@ CodePage = "65001" %>
    <% session.CodePage = "65001" %>
    <% Response.CharSet = "utf-8" %>

 + 다운로드 서블릿 페이지에서 브라우저 확인 분기

    dim strUserAgent

     ' 브라우저 버전 읽어오기

     strUserAgent = UCase(cstr(request.ServerVariables("HTTP_USER_AGENT"))

    ' ANDROID문자열을 포함하는 경우 실행

    if InStr(strUserAgent, "ANDROID") > 0  then

file_ext = UCASE(mid(savename,instr(savename,".")+1))

    if file_ext = "XLS" or file_ext = "XLSX" then
        Response.ContentType="application/vnd.ms-excel;euc-kr"
    elseif file_ext = "DOC"  or file_ext = "DOCX" then
        Response.ContentType="application/msword;euc-kr"
    elseif file_ext = "PPT"  or file_ext = "PPTX" then
        Response.ContentType="application/vnd.ms-powerpoint;euc-kr"
    elseif file_ext = "PDF"   then
        Response.ContentType="application/pdf;euc-kr"
    elseif file_ext = "JPG" or file_ext = "JPEG"  then
        Response.ContentType="image/jpg;euc-kr"
    elseif file_ext = "GIF"   then
        Response.ContentType="image/gif;euc-kr"
    elseif file_ext = "HWP" then
        Response.ContentType="application/x-hwp;euc-kr"
    else
        Response.ContentType = "application/octet-stream"
    end if
    Response.AddHeader "Content-Disposition","attachment;filename=" & server.URLPathEncode(filename)

    Else

Response.ContentType = "application/octet-stream"

Response.AddHeader "Content-Disposition","attachment;filename=" & filename

    End If

   안드로이드일 경우 헤드 설정 및 첨부파일형식에 따른 MIME을 설정해주어야 정확한 파일을 다운로드 처리할수 있었다.

이하 다운로드 로직은 기존 로직을 그대로 이용하면됨.

 

view페이지에서도 브라우저체크를하여서 브라우저가 android일경우에는 파일명 파라미터에 escape을 안하고 일반 브라우저일 경우에는 escape해서 보내도록 처리하였다. 하앍

+ Recent posts