从coldfusion中的自动下载网址获取文件

Beg*_*ner 6 coldfusion cffile cfhttp

我正在尝试使用 cfhttp 从自动下载 url 获取文件。我正在使用以下代码:

<cfhttp method="get" url="http://www.example.com/getfile" path="E:/" file="abc.csv">
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我将文件类型指定为 CSV,因此我能够获取文件,但文件类型可以更改。我试图CFHTTP.MIMETYPE获取文件类型并像这样使用:

<cfhttp method="get" url="http://www.example.com/getfile">
<cffile action="write" file="E:/abc.#listLast(cfhttp.MIMETYPE,'/')#" output="#cfhttp.FileContent#">
Run Code Online (Sandbox Code Playgroud)

这适用于 CSV 和 XML 文件。但我希望它也适用于 Excel 文件。

请帮忙。提前致谢。

Dee*_*dhy 5

<cfhttp method="get" url="http://www.example.com/getfile">
<cfset fileName = listlast(cfhttp["responseHeader"]["content-disposition"],";=")>
<cffile action="write" file="E:/abc.#fileName#" output="#cfhttp.FileContent#">
Run Code Online (Sandbox Code Playgroud)