问题描述
之前分享过如何创建dataset
在创建dataset后,需要上传本地文件到dataset中
解决方案:
注意,在eclipse中运行,会出现error:
Could not open FCCJavaClientProxy library (FCCJavaClientProxyv16064 or FCCJavaClientProxyv16064). Make sure FMS_HOME is set properly.
原因:eclipse没有设置PATH
解决:在Eclipse中, open the “Debug configuration”, select the “Environment” tab and add:
Name: PATH
Value: ${env_var:PATH}; ${env_var:FMS_HOME}\lib
并且勾选 “Append environment to native environment”
FileManagementService fmService = FileManagementService.getService(con);
FileManagementUtility fileUtility = new FileManagementUtility(con);
com.teamcenter.services.strong.core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[] inputs ={ inputData };
GetDatasetWriteTicketsResponse ticketResp = fmService.getDatasetWriteTickets(inputs);
if(!ServiceDataError(ticketResp.serviceData)) {
for(DatasetFileTicketInfo ticketInfo : ticketResp.commitInfo[0].datasetFileTicketInfos) {
String ticket = ticketInfo.ticket;
ErrorStack err = fileUtility.putFileViaTicket(ticket, localFile);
if(err == null) {
ServiceData sdata = fmService.commitDatasetFiles(ticketResp.commitInfo);
if(!ServiceDataError(sdata)) {
System.out.println("Upload successfully!");
}
}else{
ErrorStackError(err);
}
}
}