SmartlingClient { public FileUploadResponse uploadFile(String projectId, String fileUri, String fileType, String fileContent, String placeholderFormat, String placeholderFormatCustom) { NamedByteArrayResource fileContentAsResource = new NamedByteArrayResource(fileContent.getBytes(Charsets.UTF_8), fileUri); MultiValueMap<String, Object> body = new LinkedMultiValueMap<>(); body.add("fileUri", fileUri); body.add("fileType", fileType); body.add("smartling.placeholder_format", placeholderFormat); body.add("smartling.placeholder_format_custom", placeholderFormatCustom); body.add("smartling.instruction_comments_enabled", "on"); body.add("file", fileContentAsResource); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); try { FileUploadResponse response = oAuth2RestTemplate.postForObject(API_FILES_UPLOAD, requestEntity, FileUploadResponse.class, projectId); throwExceptionOnError(response, ERROR_CANT_UPLOAD_FILE, fileUri); return response; } catch(HttpClientErrorException e) { throw wrapIntoSmartlingException(e, ERROR_CANT_UPLOAD_FILE, fileUri); } } SmartlingClient(OAuth2RestTemplate oAuth2RestTemplate); Stream<StringInfo> getStringInfos(String projectId, String fileUri); Items<File> getFiles(String projectId); String downloadFile(String projectId, String locale, String fileUri, boolean includeOriginalStrings, RetrievalType retrievalType); String downloadPublishedFile(String projectId, String locale, String fileUri, boolean includeOriginalStrings); void deleteFile(String projectId, String fileUri); FileUploadResponse uploadFile(String projectId, String fileUri, String fileType, String fileContent, String placeholderFormat, String placeholderFormatCustom); FileUploadResponse uploadLocalizedFile(String projectId,
                                                  String fileUri,
                                                  String fileType,
                                                  String localeId,
                                                  String fileContent,
                                                  String placeholderFormat,
                                                  String placeholderFormatCustom); Items<StringInfo> getSourceStrings(String projectId, String fileUri, Integer offset, Integer limit); ContextUpload uploadContext(String projectId, String name, byte[] content); void createBindings(Bindings bindings, String projectId);  }
@Test public void testUploadFile() { Assume.assumeNotNull(smartlingTestConfig.projectId); uploadFile(smartlingTestConfig.projectId, "strings.xml"); }