RTC SDK: Giving names to the files uploaded
When uploading files into a repository using RTC Eclipse IDE it does not retain the original file name and asks the user to name it.
One customer created a RTC Eclipse plugin that uploads more than one file to a Work Item and noticed this same behaviour. He wants to know if there's any API that could be used in order to upload the file and keep its name.
One customer created a RTC Eclipse plugin that uploads more than one file to a Work Item and noticed this same behaviour. He wants to know if there's any API that could be used in order to upload the file and keep its name.
2 answers
If this can helps you, we programmatically add new contributions to Build Results as:
File file = new File(path);
ITeamRepository repo = ...
IContent content = repo.contentManager().storeContent(IContent.CONTENT_TYPE_UNKNOWN, null, LineDelimiter.LINE_DELIMITER_NONE, inputStream, null, null);InputStream inputStream = new FileInputStream(file); IBuildResultContribution contribution = BuildItemFactory.createBuildResultContribution(); contribution.setComponentName(componentName);
contribution.setLabel(label);
contribution.setExtendedContributionTypeId(IBuildResultContribution.ARTIFACT_EXTENDED_CONTRIBUTION_ID);
contribution.setExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_FILE_NAME, file.getName());
contribution.setExtendedContributionData(content);
ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class); IBuildResult buildResult = ...
buildClient.addBuildResultContribution(buildResult, contribution, null);
As you can see, we use the same filename from the input file:
contribution.setExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_FILE_NAME, file.getName());