com.baidu.ueditor.define.FileType Java Examples

The following examples show how to use com.baidu.ueditor.define.FileType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Base64Uploader.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {

        byte[] data = decode(content);

        long maxSize = (Long) conf.get("maxSize");

        if (!validSize(data, maxSize)) {
            return new BaseState(false, AppInfo.MAX_SIZE);
        }
        String suffix = FileType.getSuffix(FileType.JPG);
        try {
            FileService fileService = Context.FILE_SERVICE;
            String path = fileService.saveStaticFile(new ByteArrayInputStream(data), System.currentTimeMillis() + suffix);
            State state = new BaseState(true);
            state.putInfo("size", data.length);
            state.putInfo("title", "");
            state.putInfo("url", path);
            state.putInfo("type", suffix);
            return state;
        } catch (Exception e) {
            log.error("上传base64文件失败",e);
        }
        return new BaseState(false, AppInfo.IO_ERROR);
    }
 
Example #2
Source File: UeditorController.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
/**
 * ueditor上传文件
 *
 * @return 上传结果
 * @throws IOException 文件上传错误
 */
@RequestMapping(method = RequestMethod.POST, consumes = "multipart/form-data")
@ApiOperation("上传文件")
public String upload(@RequestParam(value = "upfile", required = false) MultipartFile file) throws IOException {
    String fileName = file.getOriginalFilename();
    String suffix = FileType.getSuffixByFilename(fileName);
    String path = fileService.saveStaticFile(file.getInputStream(), System.currentTimeMillis() + suffix);
    State state = new BaseState(true);
    state.putInfo("size", file.getSize());
    state.putInfo("title",fileName);
    state.putInfo("url", path);
    state.putInfo("type", suffix);
    state.putInfo("original",fileName);
    return state.toJSONString();
}
 
Example #3
Source File: LocalBase64Uploader.java    From cms with Apache License 2.0 5 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {

        byte[] data = decode(content);

        long maxSize = ((Long) conf.get("maxSize")).longValue();

        if (!validSize(data, maxSize)) {
            return new BaseState(false, AppInfo.MAX_SIZE);
        }

        String suffix = FileType.getSuffix("JPG");

        String savePath = PathFormat.parse((String) conf.get("savePath"),
                (String) conf.get("filename"));

        savePath = savePath + suffix;
        String physicalPath = (String) conf.get("rootPath") + savePath;

        /* date:2017-10-7 14:34:27
            *  xzjie
            *  修改保存文件路径
            * */
        if(StringUtils.isNotBlank(Configuration.getLocalPath())){
            physicalPath=Configuration.getLocalPath() + savePath;
        }

        State storageState = StorageManager.saveBinaryFile(data, physicalPath);

        if (storageState.isSuccess()) {
            storageState.putInfo("url", PathFormat.format(savePath));
            storageState.putInfo("type", suffix);
            storageState.putInfo("original", "");
        }

        return storageState;
    }
 
Example #4
Source File: OSSBase64Uploader.java    From cms with Apache License 2.0 5 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {

        byte[] data = decode(content);

        long maxSize = ((Long) conf.get("maxSize")).longValue();

        if (!validSize(data, maxSize)) {
            return new BaseState(false, AppInfo.MAX_SIZE);
        }

        String suffix = FileType.getSuffix("JPG");

        String savePath = PathFormat.parse((String) conf.get("savePath"),
                (String) conf.get("filename"));

        savePath = savePath + suffix;
        //String physicalPath = (String) conf.get("rootPath") + savePath;

        //State storageState = StorageManager.saveBinaryFile(data, physicalPath);
        State storageState = OSSStorageManager.saveBinaryFile(data, savePath);
        if (storageState.isSuccess()) {
            storageState.putInfo("url", PathFormat.format(savePath));
            storageState.putInfo("type", suffix);
            storageState.putInfo("original", "");
        }

        return storageState;
    }
 
Example #5
Source File: Base64Uploader.java    From sdb-mall with Apache License 2.0 3 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {
	
	byte[] data = decode(content);

	long maxSize = ((Long) conf.get("maxSize")).longValue();

	if (!validSize(data, maxSize)) {
		return new BaseState(false, AppInfo.MAX_SIZE);
	}

	String suffix = FileType.getSuffix("JPG");

	String savePath = PathFormat.parse((String) conf.get("savePath"),
			(String) conf.get("filename"));
	
	savePath = savePath + suffix;
	String physicalPath = (String) conf.get("rootPath") + savePath;

	State storageState = StorageManager.saveBinaryFile(data, physicalPath);

	if (storageState.isSuccess()) {
		storageState.putInfo("url", PathFormat.format(savePath));
		storageState.putInfo("type", suffix);
		storageState.putInfo("original", "");
	}

	return storageState;
}
 
Example #6
Source File: Base64Uploader.java    From wangmarket with Apache License 2.0 3 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {
	
	byte[] data = decode(content);

	long maxSize = ((Long) conf.get("maxSize")).longValue();

	if (!validSize(data, maxSize)) {
		return new BaseState(false, AppInfo.MAX_SIZE);
	}

	String suffix = FileType.getSuffix("JPG");

	String savePath = PathFormat.parse((String) conf.get("savePath"),
			(String) conf.get("filename"));
	
	savePath = savePath + suffix;
	String physicalPath = (String) conf.get("rootPath") + savePath;

	State storageState = StorageManager.saveBinaryFile(data, physicalPath);

	if (storageState.isSuccess()) {
		storageState.putInfo("url", PathFormat.format(savePath));
		storageState.putInfo("type", suffix);
		storageState.putInfo("original", "");
	}

	return storageState;
}
 
Example #7
Source File: Base64Uploader.java    From cms with Apache License 2.0 3 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {
	
	byte[] data = decode(content);

	long maxSize = ((Long) conf.get("maxSize")).longValue();

	if (!validSize(data, maxSize)) {
		return new BaseState(false, AppInfo.MAX_SIZE);
	}

	String suffix = FileType.getSuffix("JPG");

	String savePath = PathFormat.parse((String) conf.get("savePath"),
			(String) conf.get("filename"));
	
	savePath = savePath + suffix;
	String physicalPath = (String) conf.get("rootPath") + savePath;

	State storageState = StorageManager.saveBinaryFile(data, physicalPath);

	if (storageState.isSuccess()) {
		storageState.putInfo("url", PathFormat.format(savePath));
		storageState.putInfo("type", suffix);
		storageState.putInfo("original", "");
	}

	return storageState;
}
 
Example #8
Source File: Base64Uploader.java    From ueditor with Apache License 2.0 3 votes vote down vote up
public static State save(String content, Map<String, Object> conf) {
	
	byte[] data = decode(content);

	long maxSize = ((Long) conf.get("maxSize")).longValue();

	if (!validSize(data, maxSize)) {
		return new BaseState(false, AppInfo.MAX_SIZE);
	}

	String suffix = FileType.getSuffix("JPG");

	String savePath = PathFormat.parse((String) conf.get("savePath"),
			(String) conf.get("filename"));
	
	savePath = savePath + suffix;
	String physicalPath = (String) conf.get("rootPath") + savePath;

	State storageState = StorageManager.saveBinaryFile(data, physicalPath);

	if (storageState.isSuccess()) {
		storageState.putInfo("url", PathFormat.format(savePath));
		storageState.putInfo("type", suffix);
		storageState.putInfo("original", "");
	}

	return storageState;
}