Rav*_*mar 5 java rest web-services salesforce
我构建了一个在salesforce中创建案例的流程.现在,我正在尝试以编程方式将文件上传到该案例.基本上,客户端在服务器中手动上载文件.现在的问题是如何通过基于java rest的Web服务上传它.有任何描述这个主题的链接是很好的.
首先尝试阅读以下文档:
请参阅以下内容:
http ://www.salesforce.com/in/?
ir = 1 API doc:
http ://www.salesforce.com/us/developer/docs/api/Content /sforce_api_objects_document.htm
示例:http ://login.salesforce.com/help/doc/en/fields_useful_field_validation_formulas.htm
以下代码允许您将物理文件上载到Salesforce.com并将其附加到记录.
码:
try {
File f = new File("c:\java\test.docx");
InputStream is = new FileInputStream(f);
byte[] inbuff = new byte[(int)f.length()];
is.read(inbuff);
Attachment attach = new Attachment();
attach.setBody(inbuff);
attach.setName("test.docx");
attach.setIsPrivate(false);
// attach to an object in SFDC
attach.setParentId("a0f600000008Q4f");
SaveResult sr = binding.create(new com.sforce.soap.enterprise.sobject.SObject[] {attach})[0];
if (sr.isSuccess()) {
System.out.println("Successfully added attachment.");
} else {
System.out.println("Error adding attachment: " + sr.getErrors(0).getMessage());
}
} catch (FileNotFoundException fnf) {
System.out.println("File Not Found: " +fnf.getMessage());
} catch (IOException io) {
System.out.println("IO: " +io.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
如果有任何疑虑,请试试这个并告诉我.
| 归档时间: |
|
| 查看次数: |
10539 次 |
| 最近记录: |