From 2fbceddb098114531d9fbc8b101f97a8fe3a9661 Mon Sep 17 00:00:00 2001 From: Krisztian Mozsi Date: Sat, 14 Sep 2024 02:05:29 +0100 Subject: [PATCH 1/4] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f87044c..213eb9d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ convertapi jar - 2.12 + 2.13-SNAPSHOT ConvertAPI Java Client The ConvertAPI helps to convert various file formats. @@ -48,7 +48,7 @@ scm:git:git://github.com/ConvertAPI/convertapi-java.git scm:git:git@github.com:ConvertAPI/convertapi-java.git https://github.com/ConvertAPI/convertapi-java - v2.12 + HEAD From 81ca3ebaafa0612c7a4aa597dc4762a134b0f337 Mon Sep 17 00:00:00 2001 From: Jonas Jasas Date: Tue, 3 Jun 2025 10:45:20 +0300 Subject: [PATCH 2/4] Remove all references to Secret and ApiKey #44 --- README.md | 10 +++++----- .../main/java/com/convertapi/examples/Advanced.java | 2 +- .../com/convertapi/examples/ConversionChaining.java | 2 +- .../com/convertapi/examples/ConvertRemoteFile.java | 2 +- .../java/com/convertapi/examples/ConvertStream.java | 2 +- .../java/com/convertapi/examples/ConvertWebToPdf.java | 2 +- .../convertapi/examples/ConvertWordToPdfAndPng.java | 2 +- .../com/convertapi/examples/CreatePdfThumbnail.java | 2 +- .../java/com/convertapi/examples/SimpleConversion.java | 2 +- .../java/com/convertapi/examples/SplitAndMergePdf.java | 2 +- .../java/com/convertapi/examples/UserInformation.java | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 68514ba..fffa0eb 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ And many others files manipulations. In just few minutes you can integrate it into your application and use it easily. The ConvertAPI-Java library makes it easier to use the Convert API from your Java 8 projects without having to build your own API calls. -You can get your free API credentials at https://www.convertapi.com/a +You can get your free API token at https://www.convertapi.com/a/authentication ## Installation @@ -27,10 +27,10 @@ Add the following dependency to your pom.xml: ### Configuration -You can get your credentials at https://www.convertapi.com/a +You can get your token at https://www.convertapi.com/a/authentication ```java -Config.setDefaultApiCredentials("your-api-credentials"); +Config.setDefaultApiCredentials("api-token"); ``` ### File conversion @@ -111,13 +111,13 @@ import com.convertapi.ConvertApi; public class SimpleConversion { public static void main(String[] args) { - ConvertApi.convert("source.docx", "result.pdf", "your-api-credentials"); + ConvertApi.convert("source.docx", "result.pdf", "api-token"); } } ``` This is the bare-minimum to convert a file using the ConvertAPI client, but you can do a great deal more with the ConvertAPI Java library. -Take special note that you should replace `your-api-credentials` with the credentials you obtained in item two of the pre-requisites. +Take special note that you should replace `api-token` with the token you obtained in item two of the pre-requisites. ### Issues & Comments Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP! diff --git a/examples/src/main/java/com/convertapi/examples/Advanced.java b/examples/src/main/java/com/convertapi/examples/Advanced.java index afeb269..c85477c 100644 --- a/examples/src/main/java/com/convertapi/examples/Advanced.java +++ b/examples/src/main/java/com/convertapi/examples/Advanced.java @@ -21,7 +21,7 @@ public class Advanced { public static void main(String[] args) throws ExecutionException, InterruptedException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication // Advanced HTTP client setup Config.setDefaultHttpBuilder(builder -> { diff --git a/examples/src/main/java/com/convertapi/examples/ConversionChaining.java b/examples/src/main/java/com/convertapi/examples/ConversionChaining.java index f41e3f4..53ff39c 100644 --- a/examples/src/main/java/com/convertapi/examples/ConversionChaining.java +++ b/examples/src/main/java/com/convertapi/examples/ConversionChaining.java @@ -21,7 +21,7 @@ public class ConversionChaining { public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication System.out.println("Converting PDF to JPG and compressing result files with ZIP"); CompletableFuture jpgResult = ConvertApi.convert("docx", "jpg", new Param("file", Paths.get("files/test.docx"))); diff --git a/examples/src/main/java/com/convertapi/examples/ConvertRemoteFile.java b/examples/src/main/java/com/convertapi/examples/ConvertRemoteFile.java index 37c2a38..bcffc08 100644 --- a/examples/src/main/java/com/convertapi/examples/ConvertRemoteFile.java +++ b/examples/src/main/java/com/convertapi/examples/ConvertRemoteFile.java @@ -20,7 +20,7 @@ public class ConvertRemoteFile { public static void main(String[] args) throws ExecutionException, InterruptedException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication System.out.println("Converting remote PPTX to PDF"); CompletableFuture result = ConvertApi.convert("pptx", "pdf", diff --git a/examples/src/main/java/com/convertapi/examples/ConvertStream.java b/examples/src/main/java/com/convertapi/examples/ConvertStream.java index da392bb..460794d 100644 --- a/examples/src/main/java/com/convertapi/examples/ConvertStream.java +++ b/examples/src/main/java/com/convertapi/examples/ConvertStream.java @@ -22,7 +22,7 @@ public class ConvertStream { public static void main(String[] args) throws ExecutionException, InterruptedException, IOException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication // Creating file data stream InputStream stream = Files.newInputStream(new File("src/main/resources/test.docx").toPath()); diff --git a/examples/src/main/java/com/convertapi/examples/ConvertWebToPdf.java b/examples/src/main/java/com/convertapi/examples/ConvertWebToPdf.java index ad35ca1..6bdaa81 100644 --- a/examples/src/main/java/com/convertapi/examples/ConvertWebToPdf.java +++ b/examples/src/main/java/com/convertapi/examples/ConvertWebToPdf.java @@ -20,7 +20,7 @@ public class ConvertWebToPdf { public static void main(String[] args) throws ExecutionException, InterruptedException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication System.out.println("Converting WEB to PDF"); CompletableFuture result = ConvertApi.convert("web", "pdf", diff --git a/examples/src/main/java/com/convertapi/examples/ConvertWordToPdfAndPng.java b/examples/src/main/java/com/convertapi/examples/ConvertWordToPdfAndPng.java index f7c8f14..ff4c656 100644 --- a/examples/src/main/java/com/convertapi/examples/ConvertWordToPdfAndPng.java +++ b/examples/src/main/java/com/convertapi/examples/ConvertWordToPdfAndPng.java @@ -23,7 +23,7 @@ public class ConvertWordToPdfAndPng { public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); System.out.println("Converting DOCX to PDF and JPG in parallel"); diff --git a/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java b/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java index ddca452..65d3ecf 100644 --- a/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java +++ b/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java @@ -21,7 +21,7 @@ public class CreatePdfThumbnail { public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); System.out.println("Creating PDF thumbnail"); diff --git a/examples/src/main/java/com/convertapi/examples/SimpleConversion.java b/examples/src/main/java/com/convertapi/examples/SimpleConversion.java index 97b290d..befbbd1 100644 --- a/examples/src/main/java/com/convertapi/examples/SimpleConversion.java +++ b/examples/src/main/java/com/convertapi/examples/SimpleConversion.java @@ -11,7 +11,7 @@ public class SimpleConversion { public static void main(String[] args) { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication String resourcePath = "files/test.docx"; String tmpDir = System.getProperty("java.io.tmpdir") + "/"; diff --git a/examples/src/main/java/com/convertapi/examples/SplitAndMergePdf.java b/examples/src/main/java/com/convertapi/examples/SplitAndMergePdf.java index 22d0498..7da120c 100644 --- a/examples/src/main/java/com/convertapi/examples/SplitAndMergePdf.java +++ b/examples/src/main/java/com/convertapi/examples/SplitAndMergePdf.java @@ -21,7 +21,7 @@ public class SplitAndMergePdf { public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); System.out.println("Creating PDF with the first and the last pages"); diff --git a/examples/src/main/java/com/convertapi/examples/UserInformation.java b/examples/src/main/java/com/convertapi/examples/UserInformation.java index c09a38e..93e5c01 100644 --- a/examples/src/main/java/com/convertapi/examples/UserInformation.java +++ b/examples/src/main/java/com/convertapi/examples/UserInformation.java @@ -13,7 +13,7 @@ public class UserInformation { public static void main(String[] args) { - Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a + Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication User user = ConvertApi.getUser(); System.out.println("API Key: " + user.ApiKey); From 06c51ac174d498d14ff5478ee319a3a129624b0a Mon Sep 17 00:00:00 2001 From: Krisztian Mozsi Date: Thu, 12 Jun 2025 00:59:00 +0100 Subject: [PATCH 3/4] Fix error on InputStream conversion --- .../com/convertapi/examples/ConvertStream.java | 16 ++++++++-------- .../com/convertapi/client/RequestBodyStream.java | 9 --------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/examples/src/main/java/com/convertapi/examples/ConvertStream.java b/examples/src/main/java/com/convertapi/examples/ConvertStream.java index 460794d..a261c2d 100644 --- a/examples/src/main/java/com/convertapi/examples/ConvertStream.java +++ b/examples/src/main/java/com/convertapi/examples/ConvertStream.java @@ -25,16 +25,16 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc Config.setDefaultApiCredentials(getenv("API_TOKEN")); // Get your api token at https://www.convertapi.com/a/authentication // Creating file data stream - InputStream stream = Files.newInputStream(new File("src/main/resources/test.docx").toPath()); - - System.out.println("Converting stream of DOCX data to PDF"); - CompletableFuture result = ConvertApi.convert("docx", "pdf", + try (InputStream stream = Files.newInputStream(new File("src/main/resources/test.docx").toPath())) { + System.out.println("Converting stream of DOCX data to PDF"); + CompletableFuture result = ConvertApi.convert("docx", "pdf", new Param("file", stream, "test.docx") - ); + ); - Path pdfFile = Paths.get(System.getProperty("java.io.tmpdir") + "/myfile.pdf"); - result.get().saveFile(pdfFile).get(); + Path pdfFile = Paths.get(System.getProperty("java.io.tmpdir") + "/myfile.pdf"); + result.get().saveFile(pdfFile).get(); - System.out.println("PDF file saved to: " + pdfFile.toString()); + System.out.println("PDF file saved to: " + pdfFile.toString()); + } } } diff --git a/src/main/java/com/convertapi/client/RequestBodyStream.java b/src/main/java/com/convertapi/client/RequestBodyStream.java index 1e617d0..dbf44aa 100644 --- a/src/main/java/com/convertapi/client/RequestBodyStream.java +++ b/src/main/java/com/convertapi/client/RequestBodyStream.java @@ -19,15 +19,6 @@ public MediaType contentType() { return mediaType; } - @Override - public long contentLength() { - try { - return inputStream.available(); - } catch (IOException e) { - return 0; - } - } - @Override public void writeTo(BufferedSink sink) throws IOException { Source source = null; From 61c01247253e8f861d595c4e9ede9ebf39703b62 Mon Sep 17 00:00:00 2001 From: Krisztian Mozsi Date: Thu, 19 Jun 2025 00:20:26 +0100 Subject: [PATCH 4/4] [maven-release-plugin] prepare release v2.13 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 213eb9d..b36818f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ convertapi jar - 2.13-SNAPSHOT + 2.13 ConvertAPI Java Client The ConvertAPI helps to convert various file formats. @@ -48,7 +48,7 @@ scm:git:git://github.com/ConvertAPI/convertapi-java.git scm:git:git@github.com:ConvertAPI/convertapi-java.git https://github.com/ConvertAPI/convertapi-java - HEAD + v2.13