filerepository


save

parameter의 originalURL을  통해 원본 파일을  로컬 저장 후 저장된 파일의 정보를 JSON object 형태로 반환한다.

파일의 형태는 (json, xml, image... 등이 있다.)

options

필드설명
bizAppId비즈 앱 아이디
originalURL원본URL
fileName파일이름
isCompress

zip 파일압축여부 (압축파일이면 다운받은 후 압축을 해제)

해당 옵션은  압축된 경우에만 기술

  • "true" : 압축파일
  • "false" : 압축파일이 아님
  

successCallback

필드필드설명
result 저장된 File의 정보
fileName파일 이름
filePath파일 경로
fileSize파일 사이즈
saveData저장 시간
   

errorCallback

필드설명
없음없음
  

Example

var bizAppId    = 'main';
var originalURL = 'http://www.hsnc.co.kr/kr/mobile/mod/images/com/logo.png';
var fileName    = 'logo.png';
var isCompress  = 'false';

hone.channel.execute('FileRepository', 'save',
    [bizAppId, originalURL, fileName, isCompress],
   function (result) {
       // success callback
       alert(JSON.stringify(result));
    },
   function (e) {
       // error callback
       alert(JSON.stringify(e));
    }
);

Result

단독 파일 일 경우

{
   "fileName": "대상 파일",
   "filePath": "대상파일을 저장한 Full Path Name 정보",
   "fileSize": 6306560,
   "saveDate": "20170201"
}

다수 개 파일일 경우 

[{
   "fileName": "miss.txt",
   "filePath": "지정된 경로/main/unzip/miss.txt",
   "fileSize": 83206,
   "saveDate": "20170201"
}, {
   "fileName": "readme.txt",
   "filePath": "지정된 경로/main/unzip/readme.txt",
   "fileSize": 482,
   "saveDate": "20170201"
}]

find

bizAppIdd와 fileName을 filtering 하여 로컬에 저장된 파일을 검색한후 검색 내용을 배열(Array)로 반환한다.

위의 parameter값 중 공백으로 입력된 parameter는 항목 전체를 의미한다.

options

필드설명
bizAppId앱아이디
fileName파일명
  

successCallback 

필드필드설명
result 파일 검색 결과 (JSON array)
fileName파일 이름
filePath파일 경로
fileSize파일 사이즈
saveData저장 시간
   

errorCallback

필드설명
없음없음
  

Example

var bizAppId = 'main';
var fileName = 'logo.png';

hone.channel.execute('FileRepository', 'find',
    [bizAppId, fileName],
   function (result) {
       // success callback
       alert(JSON.stringify(result));
    },
   function (e) {
       // error callback
       alert(JSON.stringify(e));
    }
);

Result

[{
   "fileName": "logo.png",
   "filePath": "지정된 경로/main/logo.png",
   "fileSize": 8961,
   "saveDate": "20170201"
}]

remove

parameter의 localFilePath을 기준으로 로컬에 저장된 파일찾아 삭제한다.

options

필드설명
localFilePath로컬파일경로
  

successCallback

필드설명
result파일 삭제 여부
  

errorCallback

필드설명
없음없음
  

Example

var localFilePath = 'file://data/logo.png';
hone.channel.execute('FileRepository', 'remove',
    [localFilePath],
   function (result) {
       // success callback
       alert(result ? "삭제되었습니다." : "실패하였습니다.");
    },
   function (e) {
       // error callback
       alert(JSON.stringify(e));
    }
);