-4
任何人都可以請共享方法或示例代碼以使用Java在Sharepoint上上傳文件。使用Java在Sharepoint上傳文件
任何人都可以請共享方法或示例代碼以使用Java在Sharepoint上上傳文件。使用Java在Sharepoint上傳文件
我認爲這可以幫助你
public static CopySoap getPort(String username, String password) {
Copy service = new Copy();
CopySoap port = service.getCopySoap();
BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"https://my.site.com/sites/mysite/_vti_bin/copy.asmx");
return port;
}
public static void createDocument(CopySoap port) {
String url = "https://my.site.com/sites/mysite/Shared Documents/Temp Folder/test.txt";
String sourceUrl = "C:\\CopyFile\\READ-ME.txt";
DestinationUrlCollection urls = new DestinationUrlCollection();
urls.getString().add(url);
byte[] content = IoUtil.getBytes(new File(sourceUrl));
FieldInformation titleInfo = new FieldInformation();
titleInfo.setDisplayName("Title");
titleInfo.setType(FieldType.TEXT);
titleInfo.setValue("Test Doc");
FieldInformationCollection infos = new FieldInformationCollection();
infos.getFieldInformation().add(titleInfo);
CopyResultCollection results = new CopyResultCollection();
Holder<CopyResultCollection> resultHolder = new Holder<CopyResultCollection>(results);
Holder<Long> longHolder = new Holder<Long>(new Long(-1));
port.copyIntoItems(sourceUrl, urls, infos, content, longHolder, resultHolder);
}
@ user3227013如果我的回答是有幫助的,你可以選擇我的答案 – Ashish