Class BoxFilesManager
java.lang.Object
org.apache.camel.component.box.api.BoxFilesManager
Provides operations to manage Box files.
-
Constructor Summary
ConstructorsConstructorDescriptionBoxFilesManager(com.box.sdk.BoxAPIConnection boxConnection) Create files manager to manage the files of Box connection's authenticated user. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckUpload(String fileName, String parentFolderId, Long size) Does a pre-verification before upload, to check if the filename already exists or if there is permission to upload.com.box.sdk.BoxFileCopy file to destination folder while optionally giving it a new name.com.box.sdk.MetadatacreateFileMetadata(String fileId, com.box.sdk.Metadata metadata, String typeName) Create metadata for file in either the global properties template or the specified template type.com.box.sdk.BoxSharedLinkcreateFileSharedLink(String fileId, com.box.sdk.BoxSharedLink.Access access, Date unshareDate, com.box.sdk.BoxSharedLink.Permissions permissions) Create a shared link to file.voiddeleteFile(String fileId) Delete the file.voiddeleteFileMetadata(String fileId) Delete the file properties metadata.voiddeleteFileVersion(String fileId, Integer version) Delete a file version.downloadFile(String fileId, OutputStream output, Long rangeStart, Long rangeEnd, com.box.sdk.ProgressListener listener) Download a file.downloadPreviousFileVersion(String fileId, Integer version, OutputStream output, com.box.sdk.ProgressListener listener) Download a previous version of file.getDownloadURL(String fileId) Get an expiring URL for downloading a file directly from Box.com.box.sdk.BoxFile.InfogetFileInfo(String fileId, String... fields) Get file information.com.box.sdk.MetadatagetFileMetadata(String fileId, String typeName) Gets the file properties metadata.getFilePreviewLink(String fileId) Get an expiring URL for creating an embedded preview session.Collection<com.box.sdk.BoxFileVersion> getFileVersions(String fileId) Get any previous versions of file.com.box.sdk.BoxFileMove file to destination folder while optionally giving it a new name.com.box.sdk.BoxFileVersionpromoteFileVersion(String fileId, Integer version) Promote a previous version of file.com.box.sdk.BoxFilerenameFile(String fileId, String newFileName) Rename file giving it the namenewNamecom.box.sdk.BoxFileupdateFileInfo(String fileId, com.box.sdk.BoxFile.Info info) Update file information.com.box.sdk.MetadataupdateFileMetadata(String fileId, com.box.sdk.Metadata metadata) Update the file properties metadata.com.box.sdk.BoxFileuploadFile(String parentFolderId, InputStream content, String fileName, Date created, Date modified, Long size, Boolean check, com.box.sdk.ProgressListener listener) Upload a new file to parent folder.com.box.sdk.BoxFileuploadNewFileVersion(String fileId, InputStream fileContent, Date modified, Long fileSize, com.box.sdk.ProgressListener listener) Upload a new version of file.
-
Constructor Details
-
BoxFilesManager
public BoxFilesManager(com.box.sdk.BoxAPIConnection boxConnection) Create files manager to manage the files of Box connection's authenticated user.- Parameters:
boxConnection- - Box connection to authenticated user account.
-
-
Method Details
-
getFileInfo
Get file information.- Parameters:
fileId- - the id of file.fields- - the information fields to retrieve; ifnullall information fields are retrieved.- Returns:
- The file information.
-
updateFileInfo
Update file information.- Parameters:
fileId- - the id of file to update.info- - the updated information- Returns:
- The updated file.
-
uploadFile
public com.box.sdk.BoxFile uploadFile(String parentFolderId, InputStream content, String fileName, Date created, Date modified, Long size, Boolean check, com.box.sdk.ProgressListener listener) Upload a new file to parent folder.- Parameters:
parentFolderId- - the id of parent folder.content- - a stream containing contents of the file to upload.fileName- the name to give the uploaded file.created- - the content created date that will be given to the uploaded file.modified- - the content modified date that will be given to the uploaded file.size- - the size of the file's content used for monitoring the upload's progress.check- - if the file name is already used, call the uploadNewVersion instead.listener- - a listener for monitoring the upload's progress.- Returns:
- The uploaded file.
-
uploadNewFileVersion
public com.box.sdk.BoxFile uploadNewFileVersion(String fileId, InputStream fileContent, Date modified, Long fileSize, com.box.sdk.ProgressListener listener) Upload a new version of file.- Parameters:
fileId- - the id of file.fileContent- - a stream containing contents of the file to upload.modified- - the content modified date that will be given to the uploaded file.fileSize- - the size of the file's content used for monitoring the upload's progress.listener- - a listener for monitoring the upload's progress.- Returns:
- The uploaded file.
-
getFileVersions
Get any previous versions of file.- Parameters:
fileId- - the id of file.- Returns:
- The list of previous file versions.
-
downloadFile
public OutputStream downloadFile(String fileId, OutputStream output, Long rangeStart, Long rangeEnd, com.box.sdk.ProgressListener listener) Download a file.- Parameters:
fileId- - the id of file.output- - the stream to which the file contents will be written.rangeStart- - the byte offset in file at which to start the download; ifnullthe entire contents of file will be downloaded.rangeEnd- - the byte offset in file at which to stop the download; ifnullthe entire contents of file will be downloaded.listener- - a listener for monitoring the download's progress; ifnullthe download's progress will not be monitored.- Returns:
- The stream containing the contents of the downloaded file.
-
downloadPreviousFileVersion
public OutputStream downloadPreviousFileVersion(String fileId, Integer version, OutputStream output, com.box.sdk.ProgressListener listener) Download a previous version of file.- Parameters:
fileId- - the id of file.version- - the version of file to download; initial version of file has value of0, second version of file is1and so on.output- - the stream to which the version contents will be written.listener- - a listener for monitoring the download's progress; ifnullthe download's progress will not be monitored.- Returns:
- The stream containing the contents of the downloaded file version.
-
promoteFileVersion
Promote a previous version of file.- Parameters:
fileId- - the id of file.version- - the version of file to promote; initial version of file has value of0, second version of file is1and so on.- Returns:
- The promoted version of file.
-
copyFile
Copy file to destination folder while optionally giving it a new name.- Parameters:
fileId- - the id of file to copy.destinationFolderId- - the id of the destination folder.newName- - the new name for copied file; ifnewNameisnull, the copied file has same name as the original.- Returns:
- The copied file.
-
moveFile
Move file to destination folder while optionally giving it a new name.- Parameters:
fileId- - the id of file to move.destinationFolderId- - the id of the destination folder.newName- - the new name of moved file; ifnewNameisnull, the moved file has same name as the original.- Returns:
- The moved file.
-
renameFile
Rename file giving it the namenewName- Parameters:
fileId- - the id of file to rename.newFileName- - the new name of file.- Returns:
- The renamed file.
-
deleteFile
Delete the file.- Parameters:
fileId- - the id of file to delete.
-
deleteFileVersion
Delete a file version.- Parameters:
fileId- - the id of file with version to delete.version- - the version of file to delete; initial version of file has value of0, second version of file is1and so on.
-
getDownloadURL
Get an expiring URL for downloading a file directly from Box. This can be user, for example, for sending as a redirect to a browser to cause the browser to download the file directly from Box.- Parameters:
fileId- - the id of file.- Returns:
- The temporary download URL
-
getFilePreviewLink
Get an expiring URL for creating an embedded preview session. The URL will expire after 60 seconds and the preview session will expire after 60 minutes.- Parameters:
fileId- - the id of the file to get preview link on.- Returns:
- The preview link.
-
createFileMetadata
public com.box.sdk.Metadata createFileMetadata(String fileId, com.box.sdk.Metadata metadata, String typeName) Create metadata for file in either the global properties template or the specified template type.- Parameters:
fileId- - the id of the file to create metadata for.metadata- - the new metadata values.typeName- - the metadata template type name; ifnullthe global properties template type is used.- Returns:
- The metadata returned from the server.
-
getFileMetadata
Gets the file properties metadata.- Parameters:
fileId- - the id of the file to retrieve metadata for.typeName- - the metadata template type name; ifnullthe global properties template type is used.- Returns:
- The metadata returned from the server.
-
updateFileMetadata
Update the file properties metadata.- Parameters:
fileId- - the id of file to delete.metadata- - the new metadata values.- Returns:
- The metadata returned from the server.
-
deleteFileMetadata
Delete the file properties metadata.- Parameters:
fileId- - the id of file to delete.
-
checkUpload
Does a pre-verification before upload, to check if the filename already exists or if there is permission to upload. It will throw a BoxAPIResponseException if there is any problem in uploading the given file.- Parameters:
fileName- the name to give the uploaded file.parentFolderId- - the id of parent folder.size- - the size of the file's content used for monitoring the upload's progress.
-