public class BoxFilesManager extends Object
Provides operations to manage Box files.
| Constructor and Description |
|---|
BoxFilesManager(com.box.sdk.BoxAPIConnection boxConnection)
Create files manager to manage the files of Box connection's
authenticated user.
|
| Modifier and Type | Method and Description |
|---|---|
com.box.sdk.BoxFile |
copyFile(String fileId,
String destinationFolderId,
String newName)
Copy file to destination folder while optionally giving it a new name.
|
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.
|
com.box.sdk.BoxSharedLink |
createFileSharedLink(String fileId,
com.box.sdk.BoxSharedLink.Access access,
Date unshareDate,
com.box.sdk.BoxSharedLink.Permissions permissions)
Create a shared link to file.
|
void |
deleteFile(String fileId)
Delete the file.
|
void |
deleteFileMetadata(String fileId)
Delete the file properties metadata.
|
void |
deleteFileVersion(String fileId,
Integer version)
Delete a file version.
|
OutputStream |
downloadFile(String fileId,
OutputStream output,
Long rangeStart,
Long rangeEnd,
com.box.sdk.ProgressListener listener)
Download a file.
|
OutputStream |
downloadPreviousFileVersion(String fileId,
Integer version,
OutputStream output,
com.box.sdk.ProgressListener listener)
Download a previous version of file.
|
URL |
getDownloadURL(String fileId)
Get an expiring URL for downloading a file directly from Box.
|
com.box.sdk.BoxFile.Info |
getFileInfo(String fileId,
String... fields)
Get file information.
|
com.box.sdk.Metadata |
getFileMetadata(String fileId,
String typeName)
Gets the file properties metadata.
|
URL |
getFilePreviewLink(String fileId)
Get an expiring URL for creating an embedded preview session.
|
byte[] |
getFileThumbnail(String fileId,
com.box.sdk.BoxFile.ThumbnailFileType fileType,
Integer minWidth,
Integer minHeight,
Integer maxWidth,
Integer maxHeight)
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.BoxFile |
moveFile(String fileId,
String destinationFolderId,
String newName)
Move file to destination folder while optionally giving it a new name.
|
com.box.sdk.BoxFileVersion |
promoteFileVersion(String fileId,
Integer version)
Promote a previous version of file.
|
com.box.sdk.BoxFile |
renameFile(String fileId,
String newFileName)
Rename file giving it the name
newName |
com.box.sdk.BoxFile |
updateFileInfo(String fileId,
com.box.sdk.BoxFile.Info info)
Update file information.
|
com.box.sdk.Metadata |
updateFileMetadata(String fileId,
com.box.sdk.Metadata metadata)
Update the file properties metadata.
|
com.box.sdk.BoxFile |
uploadFile(String parentFolderId,
InputStream content,
String fileName,
Date created,
Date modified,
Long size,
com.box.sdk.ProgressListener listener)
Upload a new file to parent folder.
|
com.box.sdk.BoxFile |
uploadNewFileVersion(String fileId,
InputStream fileContent,
Date modified,
Long fileSize,
com.box.sdk.ProgressListener listener)
Upload a new version of file.
|
public BoxFilesManager(com.box.sdk.BoxAPIConnection boxConnection)
boxConnection - - Box connection to authenticated user account.public com.box.sdk.BoxFile.Info getFileInfo(String fileId, String... fields)
fileId - - the id of file.fields - - the information fields to retrieve; if null all
information fields are retrieved.public com.box.sdk.BoxFile updateFileInfo(String fileId, com.box.sdk.BoxFile.Info info)
fileId - - the id of file to update.info - - the updated informationpublic com.box.sdk.BoxFile uploadFile(String parentFolderId, InputStream content, String fileName, Date created, Date modified, Long size, com.box.sdk.ProgressListener listener)
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.listener - - a listener for monitoring the upload's progress.public com.box.sdk.BoxFile uploadNewFileVersion(String fileId, InputStream fileContent, Date modified, Long fileSize, com.box.sdk.ProgressListener listener)
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.public Collection<com.box.sdk.BoxFileVersion> getFileVersions(String fileId)
fileId - - the id of file.public OutputStream downloadFile(String fileId, OutputStream output, Long rangeStart, Long rangeEnd, com.box.sdk.ProgressListener listener)
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; if
null the entire contents of file will be
downloaded.rangeEnd - - the byte offset in file at which to stop the download; if
null the entire contents of file will be
downloaded.listener - - a listener for monitoring the download's progress; if
null the download's progress will not be
monitored.public OutputStream downloadPreviousFileVersion(String fileId, Integer version, OutputStream output, com.box.sdk.ProgressListener listener)
fileId - - the id of file.version - - the version of file to download; initial version of file has
value of 0, second version of file is
1 and so on.output - - the stream to which the version contents will be written.listener - - a listener for monitoring the download's progress; if
null the download's progress will not be
monitored.public com.box.sdk.BoxFileVersion promoteFileVersion(String fileId, Integer version)
fileId - - the id of file.version - - the version of file to promote; initial version of file has
value of 0, second version of file is
1 and so on.public com.box.sdk.BoxFile copyFile(String fileId, String destinationFolderId, String newName)
fileId - - the id of file to copy.destinationFolderId - - the id of the destination folder.newName - - the new name for copied file; if newName is
null, the copied file has same name as the
original.public com.box.sdk.BoxFile moveFile(String fileId, String destinationFolderId, String newName)
fileId - - the id of file to move.destinationFolderId - - the id of the destination folder.newName - - the new name of moved file; if newName is
null, the moved file has same name as the
original.public com.box.sdk.BoxFile renameFile(String fileId, String newFileName)
newNamefileId - - the id of file to rename.newFileName - - the new name of file.public void deleteFile(String fileId)
fileId - - the id of file to delete.public void deleteFileVersion(String fileId, Integer version)
fileId - - the id of file with version to delete.version - - the version of file to delete; initial version of file has
value of 0, second version of file is
1 and so on.public com.box.sdk.BoxSharedLink createFileSharedLink(String fileId, com.box.sdk.BoxSharedLink.Access access, Date unshareDate, com.box.sdk.BoxSharedLink.Permissions permissions)
fileId - - the id of the file to create shared link on.access - - the access level of the shared link.unshareDate - - the date and time at which time the created shared link will
expire; if unsharedDate is null then
a non-expiring link is created.permissions - - the permissions of the created link; if
permissions is null then the created
shared link is create with default permissions.public URL getDownloadURL(String fileId)
fileId - - the id of file.public URL getFilePreviewLink(String fileId)
fileId - - the id of the file to get preview link on.public byte[] getFileThumbnail(String fileId, com.box.sdk.BoxFile.ThumbnailFileType fileType, Integer minWidth, Integer minHeight, Integer maxWidth, Integer maxHeight)
fileId - - the id of the file to get preview link on.fileType - - either PNG of JPG.minWidth - - minimum width.minHeight - - minimum height.maxWidth - - maximum width.maxHeight - - maximum height.public com.box.sdk.Metadata createFileMetadata(String fileId, com.box.sdk.Metadata metadata, String typeName)
fileId - - the id of the file to create metadata for.metadata - - the new metadata values.typeName - - the metadata template type name; if null the
global properties template type is used.public com.box.sdk.Metadata getFileMetadata(String fileId, String typeName)
fileId - - the id of the file to retrieve metadata for.typeName - - the metadata template type name; if null the
global properties template type is used.public com.box.sdk.Metadata updateFileMetadata(String fileId, com.box.sdk.Metadata metadata)
fileId - - the id of file to delete.metadata - - the new metadata values.public void deleteFileMetadata(String fileId)
fileId - - the id of file to delete.Apache Camel