Class UploadBuilder
java.lang.Object
nl.bimbase.bimworks.client.upload.UploadBuilder
A convenient builder to construct the arguments for uploading a model
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDetermines the filename from the data given so far, generally not required to call this manually.long
Determines the filesize from the given data so far, generally not required to call this manuallySets the filename.filesize
(long filesize) Set the filesize manually.forceReprocessing
(boolean forceReprocessing) from
(com.google.common.io.ByteSource byteSource) Instruct the UploadBuilder to read the actual data from the given ByteSource (From the Google Guava library)fromBytes
(byte[] bytes) Instruct the UploadBuilder to read the actual data from the given byte[].Instruct the UploadBuilder to read the actual data from the given FilefromInputStream
(InputStream inputStream) Instruct the UploadBuilder to read the actual data from the given InputStream.fromInputStream
(InputStream inputStream, long filesize) Instruct the UploadBuilder to read the actual data from the given InputStream.fromInputStreamNoCheck
(InputStream inputStream, long filesize) Instruct the UploadBuilder to read the actual data from the given InputStream.Instruct the UploadBuilder to read the actual data from the given Pathcom.google.common.io.ByteSource
getPath()
nl.sascom.backplane.common.ProgressListener
long
getUrl()
nl.bimbase.bimworks.api.render.ValidationLevel
boolean
boolean
option
(UploadOption uploadOption) Deprecated.This will be removed in the futureprogressListener
(nl.sascom.backplane.common.ProgressListener progressListener) Attach a progress listener, for feedback on the progress of the upload once it has started.void
setContentType
(String contentType) Manually set the Content-TypesuppressDebugMessages
(boolean suppressDebugMessages) Instruct BIM.works Repository to suppress any debug messages.Instruct the UploadBuilder to read the actual data from the given URL.urlPassThrough
(URL url, long filesize) Instruct the UploadBuilder to pass the given URL to the BIM.works Repository and to start processing it.validationLevel
(nl.bimbase.bimworks.api.render.ValidationLevel validationLevel) Set the validation level.
-
Constructor Details
-
UploadBuilder
Create a new UploadBuilder- Parameters:
nodeUuid
- The UUID of the Node that you intend to upload to
-
-
Method Details
-
fromPath
Instruct the UploadBuilder to read the actual data from the given Path- Parameters:
path
- The Path on which to find the data to upload- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
fromFile
Instruct the UploadBuilder to read the actual data from the given File- Parameters:
file
- The File in which to find the data to upload- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
fromInputStream
public UploadBuilder fromInputStream(InputStream inputStream, long filesize) throws UploadBuilderException Instruct the UploadBuilder to read the actual data from the given InputStream. The client will always read and send the full stream, regardless of the provided filesize.- Parameters:
inputStream
- The stream to take the data from, called stays responsible for closing the InputStream.filesize
- The size in bytes of the data that is provided.- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
fromInputStreamNoCheck
public UploadBuilder fromInputStreamNoCheck(InputStream inputStream, long filesize) throws UploadBuilderException Instruct the UploadBuilder to read the actual data from the given InputStream. The client will always read and send the full stream, regardless of the provided filesize. This implementation does not check for previous data set on the UploadBuilder and will overwrite it.- Parameters:
inputStream
- The stream to take the data from, called stays responsible for closing the InputStream.filesize
- The size in bytes of the data that is provided.- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
fromInputStream
Instruct the UploadBuilder to read the actual data from the given InputStream.- Parameters:
inputStream
- The stream to take the data from, called stays responsible for closing the InputStream.- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
fromBytes
Instruct the UploadBuilder to read the actual data from the given byte[]. NoteKeep in mind that sending around large byte[] could cause heap size issues, if possible prefer reading fromfromFile(java.io.File)
,fromPath(java.nio.file.Path)
orfromInputStream(java.io.InputStream,long)
- Parameters:
bytes
- The data as a byte[]- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
url
Instruct the UploadBuilder to read the actual data from the given URL. This method will store the data in the default tmp location, and then send the data to the BIM.works Repository. UseurlPassThrough
to actually send the URL to BIM.works Repository and let the repository download the data. This can be a more efficient way to pass large models to the BIM.works repository (for example from S3, Azure Blob Storage etc...). Please note that this method will download the full file to tmp storage first, so it can be very inefficient- Parameters:
url
- A URL to the location of the data- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
urlPassThrough
Instruct the UploadBuilder to pass the given URL to the BIM.works Repository and to start processing it. This method will send the URL itself to the BIM.works Repository (pass through). This can be useful when your data is not stored on your application server (or client) but for example on AWS S3, Azure Blob Storage or a similar storage solution. When using this method make sure that: - The host in the URL can be resolved (DNS) from the BIM.works Repository location - The host in the URL can be reached (routed) from the BIM.works Repository location - The URL includes the proper authentication. On AWS S3 you can use pre-signed URLs, on Azure Blob Storage you can use Shared Access Signatures (SAS) - You provide a filename, often this cannot be inferred from the URL. This method is agnostic of any storage provider, although examples are given for S3 and Azure Blob Storage.- Parameters:
url
- A URL to the location of the datafilesize
- Since it is not guaranteed that the data-sending server will include a Content-Length, and for verification purposes, the size of the file must always be specified when using this method- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
from
Instruct the UploadBuilder to read the actual data from the given ByteSource (From the Google Guava library)- Parameters:
byteSource
- The ByteSource to read the data from- Returns:
- Returns the UploadBuilder (this)
- Throws:
UploadBuilderException
- Will be thrown when a data source had already been provided
-
getNodeUuid
- Returns:
- The UUID of the Node the data will be uploaded to
-
getPath
- Returns:
- The currently set Path
-
getFilename
- Returns:
- The currently set filename
-
determineFilename
Determines the filename from the data given so far, generally not required to call this manually.- Returns:
- The determined filename
-
determineFilesize
Determines the filesize from the given data so far, generally not required to call this manually- Returns:
- The determined filesize
- Throws:
IOException
-
option
Deprecated.This will be removed in the futureProvide additional upload options.- Parameters:
uploadOption
-- Returns:
-
getUploadOption
-
getUrl
-
getTimeOutUnit
-
getTimeOutValue
public long getTimeOutValue() -
timeOut
-
getInputStream
- Returns:
- The currently configured InputStream
-
getContentType
- Returns:
- The currently configured Content-Type
-
setContentType
Manually set the Content-Type- Parameters:
contentType
- The Content-Type, should be in the same format as HTTP Header Content-Type
-
filename
Sets the filename. Note This is not a method to provide the data, it only set's the name of the file for meta-data purposes- Parameters:
filename
- The filename of the model- Returns:
- UploadBuilder (this)
-
forceReprocessing
-
isForceReprocessing
public boolean isForceReprocessing() -
getByteSource
public com.google.common.io.ByteSource getByteSource()- Returns:
- The currently set ByteSource
-
progressListener
Attach a progress listener, for feedback on the progress of the upload once it has started. Only one progress listener can be set, calling this method twice will overwrite the previous listener- Parameters:
progressListener
- The listener that should be called- Returns:
- UploadBuilder (this)
-
getProgressListener
public nl.sascom.backplane.common.ProgressListener getProgressListener()- Returns:
- The currently attached progress listener or null
-
suppressDebugMessages
Instruct BIM.works Repository to suppress any debug messages. Currently does not do anything- Parameters:
suppressDebugMessages
-- Returns:
-
isSuppressDebugMessages
public boolean isSuppressDebugMessages()- Returns:
- Whether debug messages are currently suppressed
-
validationLevel
public UploadBuilder validationLevel(nl.bimbase.bimworks.api.render.ValidationLevel validationLevel) Set the validation level. This allows you to instruct BIM.works on how strict the model should be validated. This is only IFC-level validation, for model checking please refer toModelChecksApi
The default validation level isValidationLevel.DEFAULT
- Parameters:
validationLevel
- The validation level to use- Returns:
- UploadBuilder (this)
-
getValidationLevel
public nl.bimbase.bimworks.api.render.ValidationLevel getValidationLevel()- Returns:
- The currently set validation level
-
getUrlPassThrough
- Returns:
- Any currently set passthrough URL
-
filesize
Set the filesize manually. Generally this is not required and will be done automatically, but for example for urlPassThrough uploads this is required.- Parameters:
filesize
- The size of the file in bytes- Returns:
- UploadBuilder (this)
-