MFile Framework 에 대한 필수 API 를 정의
File IO 기능에 대한 API 를 제공
Changed in version 2.2.0
Arguments
- options(Object) - API 파라메터 Object
- path(String) - 파일 및 폴더 경로
- type(String) - 파일 및 폴더 여부 ([FILE:파일](FILE:파일) 타입,DIR:폴더 타입)
Result
- result(Object) - API 결과 Object
- status(String) - "SUCCESS" or "FAIL"
- path(String) - 파일 Path 경로
- alias(String) - 파일 alias 경로
- source(String) - 파일 source 경로
- fullpath(String) - 파일 fullpath 경로
var result = M.file.create({
'type': 'DIR',
'path': 'doc://temp'
});
console.log(result);
var result = M.file.create({
type: 'FILE',
path: 'doc://temp/hello.txt'
});
Changed in version 2.2.0
- File 의 Contents를 읽어 반환한다.
Arguments
- options(Object) - API 파라메터 Object
- path(String) - 파일 및 폴더 경로
- encoding(String) - 파일 인코딩 (UTF-8, EUC-KR, BASE64)
- indicator(String) - 파일 로딩시 표시할 indicator의 message
- callback(function) - 파일 읽기 완료 후 callback 되는 함수
Arguments
- status(String) - status 상태 코드 (SUCCESS:성공 코드, FAIL:실패 코드)
- result(Object) - 파일 정보
- message(String) - 메세지
- size(int) - 파일 데이터 길이
- data(String) - 파일의 text 데이터 (바이너리 파일의 경우 base64 데이터), 값이 [BLOB] 인 경우 읽을 수 없는 바이너리 파일
- path(String) - 파일 Path 경로
- alias(String) - 파일 alias 경로
- source(String) - 파일 source 경로
- fullpath(String) - 파일 fullpath 경로
M.file.read({
path: 'doc://temp/hello.txt',
encoding: 'UTF-8',
indicator: true,
callback: function(status,result){
console.log(status + JSON.stringify(result));
}
});
M.file.read({
path: '/storage/emulated/0/DCIM/Camera/sample_img.png',
encoding: 'BASE64',
indicator: true,
callback: function(status,result){
console.log(status + JSON.stringify(result));
var imgView = document.getElementById('imageView');
//mime-type은 별도로 스크립트에서 지정 필요
imgView.src = "data:image/png;base64,"+result.data;
}
});
Changed in version 2.2.0
Arguments
- options(Object) - API 파라메터 Object
- path(String) - 파일 및 폴더 경로
Result
- result(Object) - API 결과 Object
- status(String) - "SUCCESS" or "FAIL"
- path(String) - 파일 Path 경로
- alias(String) - 파일 alias 경로
- source(String) - 파일 source 경로
- fullpath(String) - 파일 fullpath 경로
var result = M.file.remove({
type: 'DIR',
path: 'doc://temp/'
});
M.tool.log(result);
alert(JSON.stringify(result));
var result = M.file.remove({
path: 'doc://temp/hello.txt'
});
console.log(result);
Changed in version 2.2.0
- File 및 directory의 정보를 가져온다.
Arguments
- options(Object) - API 파라메터 Object
- path(String) - (source) 원본 경로
Result
- result(Object) - API 결과 Object
- status(String) - "SUCCESS" or "FAIL"
- path(String) - 파일 Path 경로
- alias(String) - 파일 alias 경로
- source(String) - 파일 source 경로
- fullpath(String) - 파일 fullpath 경로
- name(String) - 파일 이름
- type(String) - 파일 및 폴더 여부 ([FILE:파일](FILE:파일) 타입,DIR:폴더 타입)
- create(String) - 파일 생성일
- created(String) - 파일 생성일
- update(String) - 파일 수정일
- updated(String) - 파일 수정일
var result = M.file.info({
path: 'doc://temp/'
});
console.log(result);
Changed in version 2.2.0
- File 및 directory의 목록을 가져온다.
Arguments
- options(Object) - API 파라메터 Object
- path(String) - (source) 원본 경로
- filter(String) - 파일 및 폴더 여부 ([FILE:파일](FILE:파일) 타입,DIR:폴더 타입)
Result
- result(Object) - API 결과 Object
- status(String) - "SUCCESS" or "FAIL"
- dir_count(int) - 폴더 갯수
- dir_list(array) - 폴더 리스트
- list(array) - 파일 리스트
- path(String) - 파일 Path 경로
- alias(String) - 파일 alias 경로
- source(String) - 파일 source 경로
- fullpath(String) - 파일 fullpath 경로
- name(String) - 파일 이름
- type(String) - 파일 및 폴더 여부 ([FILE:파일](FILE:파일) 타입,DIR:폴더 타입)
var result = M.file.list({
path: 'doc://temp/',
filter: 'DIR'
});
console.log(result);
- 파일 정보 획득 (temp 폴더내의 파일 정보 획득 예시)
var result = M.file.list({
path: 'doc://temp/',
filter: 'FILE'
});
console.log(result);
Changed in version 2.2.0
Arguments
- options(Object) - API 파라메터 Object
- type(String) - 파일 및 폴더 여부 ([FILE:파일](FILE:파일) 타입,DIR:폴더 타입)
- source(String) - (source) 원본 경로
- destination(String) - (destination) 복사될 경로
- overwrite(boolean) - 덮어쓰기 여부
- indicator(String) - 파일 복사시 표시할 indicator 여부
- progress(function) - 파일 복사 중 진행 상태를 알려주는 함수
- finish(function) - 파일 복사 완료 후 callback 되는 함수
Arguments
- total(String) - 복사할 전체 파일 크기
- current(String) - 복사된 파일 크기
Arguments
- status(String) - status 상태 코드 (SUCCESS:성공 코드, FAIL:실패 코드}
- result(object) - 복사된 파일 정보
- message(String) - 메세지
- size(int) - 파일 데이터 길이
- data(String) - 파일의 text 데이터, 값이 [BLOB] 인 경우 바이너리 파일
- path(String) - 파일의 Scheme URL 경로
- fullpath(String) - 파일의 전체 경로
M.file.copy({
type: 'FILE',
source: 'doc://temp/hello.txt',
destination: 'doc://temp/hello1.txt',
indicator: true,
progress: function(total, current, setting){
console.log(total, current);
},
finish: function(result){
console.log(result);
}
});
Changed in version 2.2.0
Arguments
- options(Object) - API 파라메터 Object
- type(String) - 파일 및 폴더 여부 ([FILE:파일](FILE:파일) 타입,DIR:폴더 타입)
- source(String) - (source) 원본 경로
- destination(String) - (destination) 복사될 경로
- overwrite(boolean) - 덮어쓰기 여부
- indicator(String) - 파일 복사시 표시할 indicator 여부
- progress(function) - 파일 복사 중 진행 상태를 알려주는 함수
- finish(function) - 파일 복사 완료 후 callback 되는 함수
Arguments
- total(String) - 복사할 전체 파일 크기
- current(String) - 복사된 파일 크기
Arguments
- status(String) - status 상태 코드 (SUCCESS:성공 코드, FAIL:실패 코드}
- result(object) - 이동된 파일 정보
- message(String) - 메세지
- size(int) - 파일 데이터 길이
- data(String) - 파일의 text 데이터, 값이 [BLOB] 인 경우 바이너리 파일
- path(String) - 파일의 Scheme URL 경로
- fullpath(String) - 파일의 전체 경로
M.file.move({
type: 'FILE',
source: 'doc://temp/hello.txt',
destination: 'doc://temp/hello1.txt',
indicator: true,
progress: function(total, current, setting){
console.log(total, current);
},
finish: function(result){
console.log(result);
}
});
Changed in version 2.2.0
Arguments
- options(Object) - API 파라메터 Object
- path(String) - 파일 및 폴더 경로
- contents(String) - 데이터
- encoding(String) - 파일 인코딩 (UTF-8, EUC-KR)
- indicator(String) - 파일 생성시 표시할 indicator
- callback(function) - 파일 쓰기 완료 후 callback 되는 함수
M.file.callback (result)
Arguments
- result(String) - result 결과 코드 (SUCCESS:성공 코드, FAIL:실패 코드)
M.file.write({
path: 'doc://temp/hello.txt',
contents: '안녕하세요.',
encoding: 'UTF-8',
callback: function(result){
console.log(result);
}
});
Changed in version 2.2.0
Arguments
- options(Object) - API 파라메터 Object
- type(String) - android 용 mime 타입 필터
- iosType(String) - iOS 용 UTI 타입 필터
- callback(function) - 파일 선택 완료 후 callback 되는 함수
M.file.callback (status, result)
Arguments
- status(String) - status 상태 코드 (SUCCESS:성공 코드, FAIL:실패 코드)
- result(Object) - 파일 정보
- path(String) - 파일 Path 경로
- alias(String) - 파일 alias 경로
- source(String) - 파일 source 경로
- fullpath(String) - 파일 fullpath 경로
MIME Type 리스트 정보
iOS UTI 지원 타입
UTI |
UTType |
Description |
public.data |
data |
모든 문서 기본 유형 |
public.item |
item |
물리적 계층의 기본 유형 |
public.content |
content |
혼합 콘텐츠 기본 유형 |
public.text |
text |
모든 텍스트 기본 유형 |
public.image |
image |
이미지의 기본 유형 |
public.video |
video |
비디오의 기본 유형 |
M.file.picker({
type: '*/*',
iosType: 'data',
callback: function(status, result){
console.log(result);
}
});