UTF8,base64格式
大家好,
这是我的问题..。我想了解当通过多部分/表单数据上传时,文件内容是如何或以何种格式传输给服务器的。
当我试图从我的serverAlfresco上传文件和几个params到codeSalesforce时,Apex和服务器似乎没有从我的请求中识别出任何一个。同时,当我试图使用任何REST客户端测试器上传时,我工作得很好,文档被上传到服务器中。
我设法在服务器端放置了一个嗅探器,并从Salesforce-Apex代码和REST客户端Tester跟踪传入的http数据包。两者似乎是相同的,静态服务器对REST客户端响应200 OK,对我的代码响应400不好的请求。
下面是从我的嗅探器中获取的示例跟踪,如字符串所示。我想知道以下HTTP请求的主体--即,以边界字符串开头的多部分/表单-数据是如何在导线中遍历的。
它是用字符串、Blob、UTF-8、Base64编码的还是格式的?
有谁能给我提供同样的深度知识吗。关于这些格式,我发现很难理解这些格式到底是什么,以及这些格式是如何形成和解密的。
POST /alfresco/service/api/upload?alf_ticket=TICKET_f1fbae39901a12ce8e33a75b84b5931661f0acbb HTTP/1.0
SFDC_STACK_DEPTH: 1
User-Agent: SFDC-Callout/31.0
Accept: application/json
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarynwLnClZSXCKQvu3H
Pragma: no-cache
Host: myAlfrescoServer:8080
Content-Length: 581
Via: 1.1 proxy-was.net.salesforce.com:8080 (squid)
X-Forwarded-For: 10.236.12.23
Cache-Control: no-cache, max-age=259200
Connection: keep-alive
------WebKitFormBoundarynwLnClZSXCKQvu3H
Content-Disposition: form-data; name="filename"
12.txt
------WebKitFormBoundarynwLnClZSXCKQvu3H
Content-Disposition: form-data; name="description"
PPPPPPPPP
------WebKitFormBoundarynwLnClZSXCKQvu3H
Content-Disposition: form-data; name="siteid"
edms
------WebKitFormBoundarynwLnClZSXCKQvu3H
Content-Disposition: form-data; name="containerid"
documentLibrary
------WebKitFormBoundarynwLnClZSXCKQvu3H
Content-Disposition: form-data; name="filedata"; filename="12.txt"
Content-Type: text/plain
123
------WebKitFormBoundarynwLnClZSXCKQvu3H-- 发布于 2014-08-23 23:17:42
如果您需要解码服务器端的表单数据,那么您确实应该考虑使用您选择的语言中的相关帮助。在PHP中,即$_POST,在Java中,类似于文件的FileItem,或者Perl的CGI->param等等。
特别是,阿尔弗雷科的WebscriptServletRequest助手应该消除大部分的痛苦和它的声音,这是很好的工作对你。你为什么不通过你的嗅探器发送一个REST请求,并与Salesforce一号进行比较呢?你在你的Alfresco上犯了什么错误?
然而,对于您的信息,multipart/form-data是复杂的,但它的不足是它使用了7位。
以下是进一步的解读:
您可以在RFC2045第六节中找到相关部分:
6.1. Content-Transfer-Encoding Syntax
The Content-Transfer-Encoding field's value is a single token
specifying the type of encoding, as enumerated below. Formally:
encoding := "Content-Transfer-Encoding" ":" mechanism
mechanism := "7bit" / "8bit" / "binary" /
"quoted-printable" / "base64" /
ietf-token / x-token
These values are not case sensitive -- Base64 and BASE64 and bAsE64
are all equivalent. An encoding type of 7BIT requires that the body
is already in a 7bit mail-ready representation. This is the default
value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the
Content-Transfer-Encoding header field is not present.https://stackoverflow.com/questions/25465231
复制相似问题