ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 /** * <b>方法描述:</b> 文件是否超出限制 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2019-06-19 15:45:31 <br/> * * @param files * 入参|文件字节|{@link Object} * @param limit * 入参|限制|{@link int} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "文件是否超出限制", style = "判断型", type = "同步组件", comment = "test aa", version = "1.0.0", deprecated = false, author = "admin", date = "2019-06-19 03:45:31") @InParams(param = { @Param(name = "files", comment = "文件字节", type = Object.class), @Param(name = "limit", comment = "限制", type = int.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase A_checkFileSize(Object files, int limit) { try { long len = ((byte[]) files).length; double fs = (double) len / 1048576; if (fs <= limit) return ResultBase.newSuccessResult(); else return ResultBase.newFailureResult("999", "待转化文件超出现在大小,文件:[" + fs + "M],限制:[" + limit + "M]"); } catch (Exception e) { AppLog.error(e); return ResultBase.newFailureResult("999", "判断待转换文件异常。" + AppLog.errorMsg(e)); } } 交易中组件使用方式: ![](https://img.kancloud.cn/f4/d7/f4d794221504160b76d599e4ae868b39_950x750.jpg) ## 参数说明及示例 文件字节:文件字节二进制数组,示例: `__INNER__["fileByte"]` 限制:文件大小限制,单位为M(兆),示例: `17` > 根据文件二进制大小判断文件大小是否超出最大大小限制