AllowedCloudParameterExtensions
是 APIFunction 及相关函数的一个选项,用来指定允许 API 或其他输入参数使用的扩展名.
AllowedCloudParameterExtensions
AllowedCloudParameterExtensions
是 APIFunction 及相关函数的一个选项,用来指定允许 API 或其他输入参数使用的扩展名.
更多信息
- 它允许用 key__extension=val 来指定 URL 等中的输入参数,其中扩展名定义应怎样从 val 中得出传递给 API 或其他在云端执行的代码的实际值.
- 支持下列可能的扩展名:
-
"url" 从指定 URL 获取数据 "json" 将给定字符串解释为 JSON 格式 "wl" 将给定字符串解释为 Wolfram Language 数据 "csv" 将给定字符串解释为 CSV 格式 "tsv" 将给定字符串解释为 TSV 格式 "cloudobject" 从指定云对象获取数据 - AllowedCloudParameterExtensions 的可能设置包括:
-
None 不允许使用扩展名 All 允许使用任意支持的扩展名 Automatic 允许使用安全的扩展名(目前为 "json") {ext1,ext2,…} 允许任意扩展名 exti - "wl" 扩展名对应于 Wolfram 语言的数据子集.
范例
打开所有单元 关闭所有单元基本范例 (2)
部署一个接受 JSON 编码矩阵的 APIFunction:
api = CloudDeploy @ APIFunction[
"data" -> SquareRepeatingElement["Integer"],
Det[#data]&,
AllowedCloudParameterExtensions -> {"json"}
]URLExecute[api, {"data__json" -> "[[1, 2], [3, 4]]"}]部署一个接受 Wolfram 语言数据作为参数的 APIFunction:
api = CloudDeploy @ APIFunction[
"positions" -> CompoundElement[<|"city" -> "City", "country" -> "Country"|>],
GeoGraphics[{GeoMarker[#positions["city"]], Polygon[#positions["country"]]}]&,
"PNG",
AllowedCloudParameterExtensions -> {"wl"}
]URLExecute[api, {"positions__wl" -> ToString[<|"city" -> "marseille", "country" -> "italy"|>, InputForm]}]范围 (1)
部署一个可以抓取 URL 或 CloudObject 的 APIFunction:
api = CloudDeploy @ APIFunction[
"image" -> "Image",
ColorNegate[ImageResize[#image, 150]] &,
"PNG",
AllowedCloudParameterExtensions -> {"url", "cloudobject"}
]URLExecute[api, {"image__cloudobject" -> "39794024-abcc-4ac2-8d9c-a0fe635f840f"}]URLExecute[api, {"image__url" -> "https://upload.wikimedia.org/wikipedia/commons/5/53/%27Willy%27_smiling._Mary_Dillwyn_Col._1853.jpg"}]可能存在的问题 (2)
允许 "url" 或 "cloudobject" 可能会允许恶意用户以消耗很多部署者云积分的方式发送数据:
obj = CloudDeploy[Delayed[Pause[10];1, "WL"]]api = CloudDeploy[APIFunction["x" -> "Integer", #x&, AllowedCloudParameterExtensions -> {"cloudobject"}]]URLExecute[api, {"x__cloudobject" -> "https://www.wolframcloud.com/objects/60e09d7b-15f8-45cb-a7c3-ef4fb39733d8"}]设置 AllowedCloudParameterExtensions 允许 "wl" 并不意味着允许任何 Wolfram 语言表达式:
api = CloudDeploy @ APIFunction[
"col" -> "Color",
Plot[Sin[x], {x, 0, 10}, PlotStyle -> #col]&,
"PNG",
AllowedCloudParameterExtensions -> {"wl"}
]URLExecute[api, {"col__wl" -> "Quit[]"}]URLExecute[api, {"col__wl" -> "RGBColor[1,0,0]"}]相关指南
-
▪
- 云执行元数据
相关的工作流程
- 部署网络 API
文本
Wolfram Research (2017),AllowedCloudParameterExtensions,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AllowedCloudParameterExtensions.html.
CMS
Wolfram 语言. 2017. "AllowedCloudParameterExtensions." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/AllowedCloudParameterExtensions.html.
APA
Wolfram 语言. (2017). AllowedCloudParameterExtensions. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/AllowedCloudParameterExtensions.html 年
BibTeX
@misc{reference.wolfram_2026_allowedcloudparameterextensions, author="Wolfram Research", title="{AllowedCloudParameterExtensions}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/AllowedCloudParameterExtensions.html}", note=[Accessed: 11-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_allowedcloudparameterextensions, organization={Wolfram Research}, title={AllowedCloudParameterExtensions}, year={2017}, url={https://reference.wolfram.com/language/ref/AllowedCloudParameterExtensions.html}, note=[Accessed: 11-September-2026]}