Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] 可以快速的处理api接口返回值。比如把图像正确的显示出来 #331

Open
shiliu2023 opened this issue Mar 24, 2023 · 1 comment

Comments

@shiliu2023
Copy link

比如 /api/news/search 就像这种接口。返回的avatar头像这个字段的值:"avatar":["/api/__yao/form/news/download/fields.form.%E5%9B%BE%E6%A0%87?name=/20230324/CFF7A5748688FB54C99A7BB31448A7D1.png"], 是这样的?怎么处理成可以让小程序端直接显示的值?完全不知道从哪里下手

@QJAutumn
Copy link
Contributor

编写一个接口文件 在 apis目录中
utils.http.json

{
  "name": "图片下载",
  "version": "1.0.0",
  "description": "图片下载",
  "group": "utils",
  "guard": "-",
  "paths": [
    {
      "guard": "-",
      "path": "/image",
      "method": "GET",
      "process": "flows.utils.image",
      "in": ["$query.name"],
      "comments": "请求地址:http://127.0.0.1:5099/api/utils/image?name=/20230412/CA2E83A496E0D7D0B44E018EF368DD9C.jpg",

      "out": {
        "status": 200,

        "headers": {
          "Content-Disposition": "{{$query.name}}"
        }
      }
    }
  ]
}

然后在 flows.utils.image处理器中写入以下内容

{
  "label": "下载",
  "version": "1.0.0",
  "description": "下载",
  "nodes": [
    {
      "name": "数据",
      "process": "fs.system.Download",
      "args": ["{{$in.0}}", false]
    }
  ],
  "output": "{{$res.数据.content}}"
}

然后请求地址 http://127.0.0.1:5099/api/utils/image?name=/20230412/CA2E83A496E0D7D0B44E018EF368DD9C.jpg
就可以正常显示图片了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants