RELEASE 2.2.1 OR ABOVE
Return the path of uploaded files by their file types (path) and whether they are deleted (isDeleted) in Object form.
Parameters:
Name | Type | Description |
---|---|---|
fileType | string | File type whose information shall be imported. ("image", "video", "file") |
Return:
Type | Attribute | Description |
---|---|---|
Array | [ { path: "/upload/path/filename.png", isDeleted: false }, { path: "/upload/path/filename2.png", isDeleted: true }, .... ] | path and isDeleted data |
Example:
var filesData = editor.getUploadedFiles();
getUploadedFiles()
릴리즈 2.2.1 이상
Return the path of uploaded files by their file types (path) and whether they are deleted (isDeleted) in Object form.
Parameters:
Name | Type | Description |
---|---|---|
fileType | String | When file type information is not entered |
Return:
Type | Attribute | Description |
---|---|---|
Object | { image: [ { path: "/upload/path/filename.png", isDeleted: false }, { path: "/upload/path/filename2.png", isDeleted: true }, .... ], video: [], file: [] } | path and isDeleted data |
Example:
var filesData = editor.getUploadedFiles();
Example
1. Limiting the Number of Image Upload
사이냅에디터에서 제공하는 파일업로드 관련 API를 활용하여 이미지 업로드 수를 제한 할 수 있습니다.
var editorId = 'synapEditor'; var editorConfig = {}; var html = ''; var editor = new SynapEditor(editorId, editorConfig, html); editor.setEventListener('afterUploadImage', function (e) { var fileType = e.fileType; var uploadPath = e.path; e.editor.addUploadPath(fileType, uploadPath); // editor.getUploadedFiles() 을 통해 업로드된 파일을 확인하려면 반드시 사용 }); editor.setEventListener('beforeUploadImage', function (e) { var fileType = e.fileType; var uploadCount = e.uploadCount; // 업로드 중인 이미지 수 (아직 업로드 되지 않은) var imageCount = 0; e.editor.getUploadedFiles(fileType).forEach(function (info) { if (!info.isDeleted) { imageCount++; // 삭제되지 않은 이미지 개수 세기 } }); if (imageCount + uploadCount >= 5) { // 5개 까지만 허용하기 e.returnValue = false; // returnValue로 false를 반환해 업로드를 취소 alert('이미지는 5개까지만 업로드 가능합니다'); } });
관련 API