public com.silanis.esl.sdk.Document uploadApiDocument(
      String packageId, String fileName, byte[] fileBytes, Document document) {
    String path =
        template.urlFor(UrlTemplate.DOCUMENT_PATH).replace("{packageId}", packageId).build();

    String documentJson = Serialization.toJson(document);

    try {
      String response = client.postMultipartFile(path, fileName, fileBytes, documentJson);
      com.silanis.esl.api.model.Document uploadedDocument =
          Serialization.fromJson(response, com.silanis.esl.api.model.Document.class);
      return new DocumentConverter(uploadedDocument, getApiPackage(packageId)).toSDKDocument();
    } catch (RequestException e) {
      throw new EslServerException("Could not upload document to package.", e);
    } catch (Exception e) {
      throw new EslException("Could not upload document to package.", e);
    }
  }