public class DiskStorageService extends AbstractDiskBasedService implements UploadStorageService
UploadStorageService that implements storage on disk| Constructor and Description |
|---|
DiskStorageService(String storagePath) |
DiskStorageService(UploadIdFactory idFactory,
String storagePath) |
| Modifier and Type | Method and Description |
|---|---|
UploadInfo |
append(UploadInfo info,
InputStream inputStream)
Append the bytes in the give
InputStream to the upload with the given ID starting at the provided offset. |
void |
cleanupExpiredUploads(UploadLockingService uploadLockingService)
Clean up any upload data that is expired according to the configured expiration time
|
void |
copyUploadTo(UploadInfo info,
OutputStream outputStream)
Copy the uploaded bytes to the given output stream
|
UploadInfo |
create(UploadInfo info,
String ownerKey)
Create an upload location with the given upload information
|
long |
getMaxUploadSize()
Get the maximum upload size configured on this storage service
|
UploadConcatenationService |
getUploadConcatenationService()
Return the
UploadConcatenationService implementation that this upload service is using |
InputStream |
getUploadedBytes(String uploadURI,
String ownerKey)
Get the uploaded bytes corresponding to the given upload URL as a stream
|
InputStream |
getUploadedBytes(UploadId id)
Get the uploaded bytes corresponding to the given upload ID as a stream
|
Long |
getUploadExpirationPeriod()
Get the expiration period of an upload in milliseconds
|
UploadInfo |
getUploadInfo(String uploadUrl,
String ownerKey)
Method to retrieve the upload info by its upload URL
|
UploadInfo |
getUploadInfo(UploadId id)
Method to retrieve the upload info by its ID
|
String |
getUploadURI()
The URI which is configured as the upload endpoint
|
void |
removeLastNumberOfBytes(UploadInfo info,
long byteCount)
Remove the given last amount of bytes from the uploaded data
|
void |
setIdFactory(UploadIdFactory idFactory)
Set an instance if IdFactory to be used for creating identities and extracting them from uploadURIs
|
void |
setMaxUploadSize(Long maxUploadSize)
Limit the maximum upload size to the given value
|
void |
setUploadConcatenationService(UploadConcatenationService concatenationService)
Set the
UploadConcatenationService that this upload storage service should use |
void |
setUploadExpirationPeriod(Long uploadExpirationPeriod)
Set the expiration period after which an in-progress upload expires
|
void |
terminateUpload(UploadInfo info)
Terminate completed and unfinished uploads allowing the Server to free up used resources.
|
void |
update(UploadInfo uploadInfo)
Update the upload information for the provided ID.
|
getPathInStorageDirectory, getStoragePathpublic DiskStorageService(String storagePath)
public DiskStorageService(UploadIdFactory idFactory, String storagePath)
public void setIdFactory(UploadIdFactory idFactory)
UploadStorageServicesetIdFactory in interface UploadStorageServiceidFactory - The UploadIdFactory to use within this storage servicepublic void setMaxUploadSize(Long maxUploadSize)
UploadStorageServicesetMaxUploadSize in interface UploadStorageServicemaxUploadSize - The maximum upload limit to setpublic long getMaxUploadSize()
UploadStorageServicegetMaxUploadSize in interface UploadStorageServicepublic UploadInfo getUploadInfo(String uploadUrl, String ownerKey) throws IOException
UploadStorageServicegetUploadInfo in interface UploadStorageServiceuploadUrl - The URL corresponding to this upload. This parameter can be null.ownerKey - A key representing the owner of the uploadIOExceptionpublic UploadInfo getUploadInfo(UploadId id) throws IOException
UploadStorageServicegetUploadInfo in interface UploadStorageServiceid - The ID of the uploadIOException - When the service is not able to retrieve the upload informationpublic String getUploadURI()
UploadStorageServicegetUploadURI in interface UploadStorageServicepublic UploadInfo create(UploadInfo info, String ownerKey) throws IOException
UploadStorageServicecreate in interface UploadStorageServiceinfo - The Upload information to use to create the new uploadownerKey - A key representing the owner of the uploadUploadInfo object containing the information used to create the upload and its unique IDIOExceptionpublic void update(UploadInfo uploadInfo) throws IOException, UploadNotFoundException
UploadStorageServiceupdate in interface UploadStorageServiceuploadInfo - The upload info object containing the ID and information to updateIOExceptionUploadNotFoundExceptionpublic UploadInfo append(UploadInfo info, InputStream inputStream) throws IOException, TusException
UploadStorageServiceInputStream to the upload with the given ID starting at the provided offset.
This method also updates the UploadInfo corresponding to this upload. The Upload Storage server should
not exceed its max upload size when writing bytes.append in interface UploadStorageServiceinfo - The ID of the uploadinputStream - The input stream containing the bytes to appendUploadInfo for this uploadIOExceptionTusExceptionpublic void removeLastNumberOfBytes(UploadInfo info, long byteCount) throws UploadNotFoundException, IOException
UploadStorageServiceremoveLastNumberOfBytes in interface UploadStorageServiceinfo - Upload of which to remove the bytesbyteCount - The number of bytes to remove at the endUploadNotFoundExceptionIOExceptionpublic void terminateUpload(UploadInfo info) throws UploadNotFoundException, IOException
UploadStorageServiceterminateUpload in interface UploadStorageServiceinfo - The upload to terminateUploadNotFoundExceptionIOExceptionpublic Long getUploadExpirationPeriod()
UploadStorageServicegetUploadExpirationPeriod in interface UploadStorageServicepublic void setUploadExpirationPeriod(Long uploadExpirationPeriod)
UploadStorageServicesetUploadExpirationPeriod in interface UploadStorageServiceuploadExpirationPeriod - The period in millisecondspublic void setUploadConcatenationService(UploadConcatenationService concatenationService)
UploadStorageServiceUploadConcatenationService that this upload storage service should usesetUploadConcatenationService in interface UploadStorageServiceconcatenationService - The UploadConcatenationService implementation to usepublic UploadConcatenationService getUploadConcatenationService()
UploadStorageServiceUploadConcatenationService implementation that this upload service is usinggetUploadConcatenationService in interface UploadStorageServicepublic InputStream getUploadedBytes(String uploadURI, String ownerKey) throws IOException, UploadNotFoundException
UploadStorageServicegetUploadedBytes in interface UploadStorageServiceuploadURI - The URIownerKey - The owner key of this uploadOutputStream containing the bytes of the uploadIOExceptionUploadNotFoundExceptionpublic InputStream getUploadedBytes(UploadId id) throws IOException, UploadNotFoundException
UploadStorageServicegetUploadedBytes in interface UploadStorageServiceid - the ID of the uploadOutputStream containing the bytes of the uploadIOException - When retrieving the bytes from the storage layer failsUploadNotFoundException - When the proved id is not linked to an uploadpublic void copyUploadTo(UploadInfo info, OutputStream outputStream) throws UploadNotFoundException, IOException
UploadStorageServicecopyUploadTo in interface UploadStorageServiceinfo - The upload of which we should copy the bytesoutputStream - The output stream where we have to copy the bytes toUploadNotFoundExceptionIOExceptionpublic void cleanupExpiredUploads(UploadLockingService uploadLockingService) throws IOException
UploadStorageServicecleanupExpiredUploads in interface UploadStorageServiceuploadLockingService - An UploadLockingService that can be used to check and lock uploadsIOExceptionCopyright © 2019. All rights reserved.