Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Use of the library requires Java 8 or higher and can be done via one of the foll
<dependency>
<groupId>net.interfax</groupId>
<artifactId>api-client</artifactId>
<version>0.12</version>
<version>0.14</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public APIResponse sendFax(final String faxNumber, final String urlOfDoc, final
URI uri = getSendFaxUri(faxNumber, options);
return executePostRequest(
uri,
target -> target.request().header("Content-Location", urlOfDoc).header("Content-Length", 0).post(null)
target -> target.request().header("Content-Location", urlOfDoc).header("Content-Length", 0).post(Entity.entity(new byte[0], MediaType.APPLICATION_OCTET_STREAM_TYPE))
);
}

Expand Down Expand Up @@ -323,7 +323,7 @@ public APIResponse uploadDocument(final File fileToUpload, final Optional<Docume
URI outboundDocumentsUri = getOutboundDocumentsUri(fileToUpload, options);

WebTarget target = client.target(outboundDocumentsUri);
response = target.request().header("Content-Length", 0).post(null);
response = target.request().header("Content-Length", 0).post(Entity.entity(new byte[0], MediaType.APPLICATION_OCTET_STREAM_TYPE));

apiResponse = new APIResponse();
apiResponse.setStatusCode(response.getStatus());
Expand Down Expand Up @@ -390,11 +390,14 @@ public APIResponse uploadChunk(String uploadChunkToDocumentEndpoint,
.header("Range", "bytes="+startByteRange+"-"+endByteRange)
.post(Entity.entity(bytesToUpload, MediaType.APPLICATION_OCTET_STREAM_TYPE));

int expectedResponseCode = lastChunk ?
Response.Status.OK.getStatusCode():
Response.Status.ACCEPTED.getStatusCode();

if (response.getStatus() == expectedResponseCode) {
final int OK = Response.Status.OK.getStatusCode();
final int ACCEPTED = Response.Status.ACCEPTED.getStatusCode();
final int NO_CONTENT = Response.Status.NO_CONTENT.getStatusCode(); // 204: No content


if ((lastChunk && response.getStatus() == OK) ||
(!lastChunk && (response.getStatus() == ACCEPTED || response.getStatus() == NO_CONTENT))) {
log.info(
"chunk uploaded at {}; totalByesUploaded = {}; lastChunk = {}",
uploadChunkToDocumentEndpoint,
Expand Down Expand Up @@ -711,4 +714,4 @@ private void initializeClient(String username, String password) {
reentrantLock.unlock();
}
}
}
}