네이버LAB 포토에디터 API (
http://s.lab.naver.com/pe/api)
서버에 올려진 이미지를 수정하고자 할 때
GET방식으로 하면 되는데
http://s.lab.naver.com/pe/api?i=1&t=2 중간쯤의
http://s.lab.naver.com/pe/service?import=http%3A%2F%2Fexample.com%2Fuser%2Fsomebody%2F1234.jpg&exportTo=http%3A%2F%2Fexample.com%2Fmyexample%2Fimage_post.jsp%3Fpid%3D1244711925301&exportMethod=GET&exportField=file&exportTitle=example.com%EC%97%90+%EC%A0%80%EC%9E%A5%ED%95%98%EA%B8%B0
와 같이 파라미터들을 주~욱 붙여 넣어주면 된다.
파일업로드 필드(input type=file)을 통한 사용자 로컬PC 이미지를 수정하고
서버에 저장하고자 할 때
exportMethod="POST" 를 주고 시도해 보았으나 exportTo(처리)에서 exportField를 받지 못하여
결국 아래와 같이 exportMethod="BROWSER" 주고 GET 방식으로 받아서 처리하였다.
폼(입력)
01 |
< H3 >네이버 포토에디터 연동 테스트</ H3 > |
03 |
< FORM id = frm encType = multipart /form-data method = post name = frm action = http ://s.lab.naver.com/pe/service> |
04 |
< INPUT id = import name = import type = file > |
05 |
< INPUT id = exportTo name = exportTo value = http ://test.womennews.co.kr/dev/naver/naverPeDown.asp?fname={파일명} type = hidden > |
06 |
< INPUT id = exportMethod name = exportMethod value = BROWSER type = hidden > |
07 |
< INPUT id = exportMIMEType name = exportMIMEType value = image /jpeg type = hidden > |
08 |
< INPUT id = exportField name = exportField value = imageData type = hidden > |
09 |
< INPUT id = exportTitle name = exportTitle value = Save type = hidden > |
10 |
< INPUT id = redirectTo name = redirectTo value = http ://test.womennews.co.kr/dev/naver/naverPe.asp type = hidden > |
12 |
< INPUT id = btnPicEdit value=사진편집 type = submit > |
처리(저장)
02 |
Session.Codepage = 949 |
03 |
Response.Charset = "euc-kr" |
08 |
saveDir = Server.Mappath(savePath) |
10 |
Response.Write("<P>Params From NaverLAB<BR> |
13 |
For Each strKey In Request.QueryString |
14 |
Response.Write(strKey & " = " "" & Request.QueryString(strKey) & "" "<BR> |
17 |
Response.Write("[POST]<BR> |
19 |
For Each strKey In Request.Form |
20 |
Response.Write(strKey & " = " "" & Request.Form(strKey) & "" "<BR> |
26 |
fname = Request.Querystring( "fname" ) |
27 |
If fname = "" Then Response.Write("fname is Nothing <BR> |
30 |
Dim imageData, imageSaveName |
31 |
imageData = Request.QueryString( "imageData" ) |
32 |
If imageData = "" Then Response.Write("imageData is Nothing <BR> |
34 |
Response.Write("Photo In NaverLAB :<BR> |
36 |
imageSaveName = fname & ".jpg" |
39 |
Set objXML = CreateObject( "Microsoft.XMLHTTP" ) |
40 |
objXML.Open "GET" , imageData, False |
42 |
binXML = objXML.ResponseBody |
46 |
Set objADO = CreateObject( "ADODB.Stream" ) |
50 |
objADO.SaveToFile saveDir &"\"& imageSaveName, 2 |
53 |
Response.Write("Saved Photo :<BR> |
펌:
http://itzone.tistory.com/254