Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest 解码文件内容_Rest_File_Coldfusion_Decode - Fatal编程技术网

Rest 解码文件内容

Rest 解码文件内容,rest,file,coldfusion,decode,Rest,File,Coldfusion,Decode,我正在做一个项目,通过api向客户端发送一个文件。我使用PUT方法发送文件,但收到400个错误请求。检查日志后,发现我的所有文件内容都已被赋予。但是当我下载这个文件时,它的内容看起来还可以。 我可以知道如何发送文件并确保文件内容已解码吗?下面是我代码的一部分 实际上我在调用api之前确实有这段代码,不确定这段代码的bcoz是否会影响文件内容的编码 <cffile action="write" nameconflict="overwrite" file="#filename#" output

我正在做一个项目,通过api向客户端发送一个文件。我使用PUT方法发送文件,但收到400个错误请求。检查日志后,发现我的所有文件内容都已被赋予。但是当我下载这个文件时,它的内容看起来还可以。 我可以知道如何发送文件并确保文件内容已解码吗?下面是我代码的一部分

实际上我在调用api之前确实有这段代码,不确定这段代码的bcoz是否会影响文件内容的编码

<cffile action="write" nameconflict="overwrite" file="#filename#" output="#toString(invoiceXML)#">
<cfhttp url="#requestUrl#" method="PUT" result="res" throwonerror="yes">
    <cfhttpparam name="Authorization" type="header" value="Basic #token#">
    <cfhttpparam name="Content-Type" type="header" value="multipart/form-data">
    <cfhttpparam type="file" name="document" file="#filename#" >
</cfhttp>

根据URL,该文件不应进行URL编码。您确定编码发生在您发布的代码段中吗

如果引用实际上是错误的,并且文件由cfhttpparam编码,则可以尝试添加
encoded
属性:

<cfhttp url="#requestUrl#" method="PUT" result="res" throwonerror="yes">
    <cfhttpparam name="Authorization" type="header" value="Basic #token#">
    <cfhttpparam name="Authorization" type="header" value="Basic #token#">
    <cfhttpparam name="Content-Type" type="header" value="multipart/form-data">
    <cfhttpparam type="file" name="document" file="#filename#" encoded="no">
</cfhttp>


如果文件内容已经编码,您可以尝试使用函数对其进行解码。

您好,Steve,我已从服务器端请求日志,我的内容已全部编码。我试图添加encoded属性,但仍然得到400个错误请求。文档说除了表单字段外,encoded被忽略。如果目的是发送文件字段,请尝试添加multipart=“yes”。如果您试图将xml作为请求正文发送,请使用type=“body”而不是type=“file”。hi@Ageax,恐怕类型无法更改为body,因为要求是type=“file”。顺便说一句,我试图添加multipart=“yes”,但仍然是一样的。。。真的不知道为什么内容会被编码。你好@ChuanyieLim。好吧,我两个都建议了,因为我不确定要求。您是否也删除了多部分内容类型标题?因为两者都使用可能会导致问题。如果仍然没有更改,请尝试使用Fiddler检查cfhttp请求。这应该告诉您cfhttp是在编码值还是在另一端发生。@ChuanyieLim-好的。我公布了这两个选项,因为我对要求不确定。确保已删除多部分内容类型标题,因为它由multipart=yes处理。您可以使用Fiddler检查cfhttp post。那个