如何在golang请求中使用二进制数据发送--boundary_string

时间:2018-10-02 11:12:40

标签: go post multipartform-data

我想通过服务器上的golang请求在我的salesforce实例中上载一个csv文件,现在在salesforce的文档中,他们给出了一个类似

的示例
curl https://yourInstance.salesforce.com/services/data/v23.0/sobjects/Document/ -H "Authorization: Bearer token" -H "Content-Type: multipart/form-data; boundary=\"boundary_string\"" --data-binary @newdocument.json

--boundary_string
Content-Disposition: form-data; name="entity_document";
Content-Type: application/json

{
   "Description" : "Marketing brochure for Q1 2011",
   "Keywords" : "marketing,sales,update",
   "FolderId" : "005D0000001GiU7",
   "Name" : "Marketing Brochure Q1",
   "Type" : "pdf"
}

--boundary_string
Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"

Binary data goes here.

--boundary_string--

那么我该如何在golang中转换此请求?

0 个答案:

没有答案