Skip to content

Commit

Permalink
Add X-File-Size header to validation requests
Browse files Browse the repository at this point in the history
  • Loading branch information
EkaterinaKomar committed Nov 27, 2023
1 parent aaa5100 commit 4842603
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 61 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ and use curl:
curl -F "url=file:///home/folder/pdf.pdf" localhost:8080/api/validate/url/1b
```

To add file size in validation POST requests you need to send request with header (key `X-File-Size` and value in bytes).
For example to use request `http://localhost:8080/api/validate/url/*id*` with file which size is 300 KB run:

```
curl -H "X-File-Size: 307200" -F "url=http://www.pdf995.com/samples/pdf.pdf" localhost:8080/api/validate/url/auto
```

### veraPDF configuration parameters
Configuration parameters are located in `/opt/verapdf-rest/config` folder of the container file system. The details on the veraPDF parameters are available at https://docs.verapdf.org/cli/config/.

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/verapdf/rest/resources/ApiResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public static ReleaseDetails getReleaseDetails() {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = Environment.class)
), @Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = Environment.class)
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Environment getEnvironment() {
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/verapdf/rest/resources/ByteStreamResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.openpreservation.bytestreams.ByteStreamId;
import org.openpreservation.bytestreams.ByteStreams;
import org.verapdf.ReleaseDetails;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
Expand Down Expand Up @@ -52,11 +51,11 @@ public ByteStreamResource() {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)),
@Schema(implementation = ByteStreamId.class)),
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)),
@Schema(implementation = ByteStreamId.class)),
@Content(mediaType = "text/xml", schema =
@Schema(implementation = ReleaseDetails.class))
@Schema(implementation = ByteStreamId.class))
})})
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
Expand Down Expand Up @@ -88,11 +87,11 @@ public static ByteStreamId getSha1(
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)),
@Schema(implementation = ByteStreamId.class)),
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)),
@Schema(implementation = ByteStreamId.class)),
@Content(mediaType = "text/xml", schema =
@Schema(implementation = ReleaseDetails.class))
@Schema(implementation = ByteStreamId.class))
})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
MediaType.TEXT_XML})
Expand Down
25 changes: 12 additions & 13 deletions src/main/java/org/verapdf/rest/resources/ProfileResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.verapdf.ReleaseDetails;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.validation.profiles.*;

Expand Down Expand Up @@ -46,9 +45,9 @@ public class ProfileResource {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = ProfileDetails.class)
), @Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = ProfileDetails.class)
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Set<ProfileDetails> getProfileDetails() {
Expand All @@ -64,9 +63,9 @@ public static Set<ProfileDetails> getProfileDetails() {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = String.class)
), @Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = String.class)
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Set<String> getProfileIds() {
Expand All @@ -82,9 +81,9 @@ public static Set<String> getProfileIds() {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = PDFAFlavour.class)
), @Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = PDFAFlavour.class)
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Set<PDFAFlavour> getFlavours() {
Expand All @@ -103,9 +102,9 @@ public static Set<PDFAFlavour> getFlavours() {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = ValidationProfile.class)
), @Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = ValidationProfile.class)
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static ValidationProfile getProfile(@Parameter(description = "the String id of the Validation profile " +
Expand All @@ -128,9 +127,9 @@ public static ValidationProfile getProfile(@Parameter(description = "the String
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = RuleId.class)
), @Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = RuleId.class)
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Set<RuleId> getProfileRules(@Parameter(description = "the String id of the Validation profile " +
Expand Down Expand Up @@ -160,9 +159,9 @@ public static Set<RuleId> getProfileRules(@Parameter(description = "the String i
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", content = {
@Content(mediaType = "application/json", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = Rule.class)
), @Content(mediaType = "application/xml", schema =
@Schema(implementation = ReleaseDetails.class)
@Schema(implementation = Rule.class)
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Set<Rule> getRulesForClause(@Parameter(description = "the String id of the Validation profile " +
Expand Down
Loading

0 comments on commit 4842603

Please sign in to comment.