Skip to content

Commit

Permalink
Merge pull request #2026 from scireum/feature/jvo/OX-10782-Blob-URL
Browse files Browse the repository at this point in the history
Blob URIs
  • Loading branch information
jakobvogel authored Aug 6, 2024
2 parents 29f93e7 + cf48e24 commit 468e42f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/sirius/biz/storage/layer2/URLBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,31 @@ public String buildImageURL() {
return safeBuildURL(IMAGE_FALLBACK_URI);
}

/**
* Builds the URL for {@linkplain sirius.web.templates.pdf.TagliatellePDFContentHandler embedding the blob into a
* PDF}. This is done via a special {@link sirius.biz.web.BlobPdfReplaceHandler blob://} URI.
* <p>
* If the image is not available, a {@linkplain #fallbackUri fallback} URI using the
* {@link sirius.web.templates.pdf.handlers.ResourcePdfReplaceHandler resource://} scheme is returned.
*
* @return a <tt>blob://</tt> URI, or a <tt>resource://</tt> URI pointing to a fallback image in case of errors
*/
public String buildUrlForEmbeddingIntoPdf() {
if (space == null || Strings.isEmpty(blobKey)) {
return "resource:/" + Optional.ofNullable(fallbackUri)
.filter(Strings::isFilled)
.map(string -> string.startsWith("assets/") ? '/' + string : string)
.filter(string -> string.startsWith("/assets/"))
.orElse(IMAGE_FALLBACK_URI);
}

StringBuilder builder = new StringBuilder("blob://").append(space.getName()).append('/').append(blobKey);
if (Strings.isFilled(variant)) {
builder.append('/').append(variant);
}
return builder.toString();
}

/**
* Determines if a conversion for the given variant is expected.
*
Expand Down

0 comments on commit 468e42f

Please sign in to comment.