企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 /** * <b>方法描述:</b> 文件是否超出限制 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2019-06-14 11:08:19 <br/> * * @param files * 入参|文件字节|{@link Object} * @param limit * 入参|限制|{@link int} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "文件是否超出限制(文件名)", style = "判断型", type = "同步组件", version = "1.0.0", deprecated = false, author = "admin", date = "2019-06-14 11:08:19") @InParams(param = { @Param(name = "files", comment = "文件字节", type = String.class), @Param(name = "limit", comment = "限制", type = int.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase A_checkFileSizeFilePath(String filepath, int limit) { try { File f = new File(filepath); if (!f.exists()) return ResultBase.newFailureResult("999", "文件不存在。"); long len = f.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/91/25/912519481a73096c363d0d1559672a47_950x750.jpg) ## 参数说明及示例 文件字节:文件名全路径二进制数组,示例: `__INNER__["filename"]` 限制:文件大小限制,单位为M(兆),示例: `17` > 根据文件全路径判断文件大小是否超出最大大小限制