public class DownloadBuilder extends Object
stored objects
.Modifier | Constructor and Description |
---|---|
protected |
DownloadBuilder(Storage storage,
String bucket,
String objectKey)
Creates a new builder with a direct reference to the storage and the object key.
|
protected |
DownloadBuilder(Storage storage,
VirtualObject object)
Creates a new builder with a direct reference to the storage and the object.
|
Modifier and Type | Method and Description |
---|---|
DownloadBuilder |
asDownload(String filename)
Make the URL a downlod url using the given filename.
|
Optional<String> |
buildURL()
Builds the effective URL according to the parameters specified wrapped in an
Optional . |
DownloadBuilder |
eternallyValid()
Makes this URL eternally valid (authenticated).
|
String |
getAddonText() |
String |
getBaseURL() |
String |
getBucket() |
String |
getFileExtension() |
String |
getFilename() |
String |
getObjectKey() |
String |
getPhysicalKey() |
boolean |
isEternallyValid() |
DownloadBuilder |
withAddonText(String text)
Permits to add additional text to the URL which is ignored by the storage layer.
|
DownloadBuilder |
withBaseURL(String baseURL)
Specifies the base URL to use.
|
DownloadBuilder |
withFileExtension(String fileExtension)
Specifies the file extension to append to the URL.
|
DownloadBuilder |
withVersion(String version)
Specifies the version of the file to use.
|
protected DownloadBuilder(Storage storage, String bucket, String objectKey)
storage
- the storage implementationbucket
- the bucket in which the object is placedobjectKey
- the object key to downloadprotected DownloadBuilder(Storage storage, VirtualObject object)
storage
- the storage implementationobject
- the object key downloadpublic DownloadBuilder withFileExtension(String fileExtension)
fileExtension
- the extension to appendpublic DownloadBuilder withVersion(String version)
The syntax is a comma separated string of key-value pairs in the form of key:value
. The available keys
are size
for the requested maximum size, min
for the minimum size and imageFormat
for
the imageFormat. The value for the size key has to be in the format <width>x<height>
.
If no external command line command is setup for the image conversion only "png" and "jpg" are supported as formats. The Default version which is used is the jpg format.
Example: The version size:500x500,min:100x100,imageFormat:png
would scale an image with 1000x800 pixels
to 500x400. An image with 1000x150 would be scaled to 500x75 and then extended with a white border to 500x100. An
image with 400x50 pixels would not be scaled but extended to 400x100. All files would be in png format.
version
- the name of the version to usepublic DownloadBuilder asDownload(String filename)
filename
- the filename to send to the browserpublic DownloadBuilder withBaseURL(String baseURL)
baseURL
- the base URL to usepublic DownloadBuilder eternallyValid()
public DownloadBuilder withAddonText(String text)
This might be used to add SEO texts for image URLs...
text
- the text to include in the URL (will be escaped properly).public Optional<String> buildURL()
Optional
.
Optional.empty()
is returned when the file cannot be found in the storage engine.
Optional
or Optional.empty()
if no file was found in the storage enginepublic String getObjectKey()
public String getFileExtension()
public String getFilename()
public String getBaseURL()
public String getPhysicalKey()
public String getBucket()
public boolean isEternallyValid()
public String getAddonText()
Copyright © 2018. All rights reserved.