Fx.file:处理和文件有关的API
1、给图片加水印-watermark
定义:Fx.file.watermark(<String nPath>,<List<String> words>)
| 参数 | 说明 |
|---|---|
| nPath | 图片的npath |
| words | 水印的内容 |
data返回值类型:Map Key |Type|说明| -|-|- path |String |执行成功的path
例:
def ret = Fx.file.watermark("N_202003_04_c706c31390b747408bfb5eef3b031f34",["test123","tyrdyz"])2、文件上传-uploadFile
定义:Fx.file.uploadFile( <String extensionName>,<String fileSize>,<byte[] fileBytes> )
| 参数 | 说明 |
|---|---|
| extensionName | 文件扩展名 |
| fileSize | 文件大小 |
| fileBytes | 文件内容byte数组 |
data返回值类型:Map Key |Type|说明| -|-|- path |String |文件npath size |long |文件大小 extensionName |String | 文件扩展名
例:
def text = "aaa" as String
def byteData = Strings.toUTF8Bytes(text)
def ret = Fx.file.uploadFile(".txt",byteData.size(),byteData)3、文件下载-downloadFile
定义:Fx.file.downloadFile( <String nPath>)
| 参数 | 说明 |
|---|---|
| nPath | 图片的npath |
data返回值类型:Map
| Key | Type | 说明 |
|---|---|---|
| fileData | byte[] | 文件内容 |
| extensionName | String | 文件扩展名 |
| fileSize | long | 文件大小 |
例:
def ret = Fx.file.downloadFile("N_202007_12_001731386ccf40698523c39744b0161c") def fileDowloadData = ret[1] def fileData = fileDowloadData['fileData'] as byte[] def str = Strings.toUTF8String(fileData) as String
4、文件打包发送给指定用户-Fx.file.packedFile
定义:Fx.file.packedFile( <List packFileList> ,<List userIdList>)
| 参数 | 说明 |
|---|---|
| packFileList | 发送的文件List |
| userIdList | 发送的人员名单 |
data返回值类型:Map
例:
UserFile file = UserFile.of("文件1","N_201907_31_57a33fb0c999447bb93fa1e4cc6e649d","jpg","/image")
List packFileList = []
packFileList.add(file)
def (Boolean error,List data,String errorMessage) = Fx.file.packedFile(packFileList,["1000"])








