Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove alternative converter support #41

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 secret at https://www.convertapi.com/a
You can get your free API credentials at https://www.convertapi.com/a

## Installation

Expand All @@ -19,21 +19,18 @@ Add the following dependency to your pom.xml:
<dependency>
<groupId>com.convertapi.client</groupId>
<artifactId>convertapi</artifactId>
<version>2.10</version>
<version>2.11</version>
</dependency>
```

## Usage

### Configuration

You can get your secret at https://www.convertapi.com/a
You can get your credentials at https://www.convertapi.com/a

```java
Config.setDefaultSecret("your-api-secret");
// or token authentication
Config.setDefaultToken("your-token");
Config.setDefaultApiKey("your-api-key");
Config.setDefaultApiCredentials("your-api-secret");
```

### File conversion
Expand Down Expand Up @@ -98,7 +95,7 @@ int conversionsConsumed = user.ConversionsConsumed;
Create `Config` instance with the alternative domain and provide it in `convert` method. Dedicated to the region [domain list](https://www.convertapi.com/doc/servers-location).

```java
Config config = new Config(secret, "https", "eu-v2.convertapi.com", 0, httpClientBuilder);
Config config = new Config(credentials, "https", "eu-v2.convertapi.com", 0, httpClientBuilder);
```

### More examples
Expand All @@ -114,13 +111,13 @@ import com.convertapi.ConvertApi;

public class SimpleConversion {
public static void main(String[] args) {
ConvertApi.convert("source.docx", "result.pdf", "your-api-secret");
ConvertApi.convert("source.docx", "result.pdf", "your-api-credentials");
}
}
```

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-secret` with the secret you obtained in item two of the pre-requisites.
Take special note that you should replace `your-api-credentials` with the secret you obtained in item two of the pre-requisites.

### Issues &amp; Comments
Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP!
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.convertapi.client</groupId>
<artifactId>convertapi</artifactId>
<version>2.10</version>
<version>2.11</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class Advanced {

public static void main(String[] args) throws ExecutionException, InterruptedException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a

// Advanced HTTP client setup
Config.setDefaultHttpBuilder(builder -> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class ConversionChaining {

public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a

System.out.println("Converting PDF to JPG and compressing result files with ZIP");
CompletableFuture<ConversionResult> jpgResult = ConvertApi.convert("docx", "jpg", new Param("file", Paths.get("files/test.docx")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class ConvertRemoteFile {

public static void main(String[] args) throws ExecutionException, InterruptedException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a

System.out.println("Converting remote PPTX to PDF");
CompletableFuture<ConversionResult> result = ConvertApi.convert("pptx", "pdf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class ConvertStream {

public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a

// Creating file data stream
InputStream stream = Files.newInputStream(new File("src/main/resources/test.docx").toPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class ConvertWebToPdf {

public static void main(String[] args) throws ExecutionException, InterruptedException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a

System.out.println("Converting WEB to PDF");
CompletableFuture<ConversionResult> result = ConvertApi.convert("web", "pdf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class ConvertWordToPdfAndPng {

public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));

System.out.println("Converting DOCX to PDF and JPG in parallel");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class CreatePdfThumbnail {

public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));

System.out.println("Creating PDF thumbnail");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class SimpleConversion {

public static void main(String[] args) {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
String resourcePath = "files/test.docx";
String tmpDir = System.getProperty("java.io.tmpdir") + "/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class SplitAndMergePdf {

public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));

System.out.println("Creating PDF with the first and the last pages");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class UserInformation {

public static void main(String[] args) {
Config.setDefaultSecret(getenv("CONVERTAPI_SECRET")); //Get your secret at https://www.convertapi.com/a
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
User user = ConvertApi.getUser();

System.out.println("API Key: " + user.ApiKey);
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/com/convertapi/client/ConvertApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ public static CompletableFuture<ConversionResult> convert(String fromFormat, Str
.addPathSegment("to")
.addPathSegment(toFormat);

for (Param param : params) {
if (param.getName().equalsIgnoreCase("converter")) {
try {
urlBuilder = urlBuilder
.addPathSegment("converter")
.addPathSegment(param.getValue().get(0));
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}

HttpUrl url = urlBuilder.addQueryParameter("storefile", "true").build();

MultipartBody.Builder multipartBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
Expand Down