Modifier and Type | Class and Description |
---|---|
class |
BoxFile.Info
Contains information about a BoxFile.
|
static class |
BoxFile.Permission
Enumerates the possible permissions that a user can have on a file.
|
Modifier and Type | Field and Description |
---|---|
static String[] |
ALL_FIELDS
An array of all possible file fields that can be requested when calling
getInfo() . |
Constructor and Description |
---|
BoxFile(BoxAPIConnection api,
String id)
Constructs a BoxFile for a file with a given ID.
|
Modifier and Type | Method and Description |
---|---|
BoxComment.Info |
addComment(String message)
Adds a comment to this file.
|
BoxFile.Info |
copy(BoxFolder destination)
Copies this item to another folder.
|
BoxFile.Info |
copy(BoxFolder destination,
String newName)
Copies this item to another folder and gives it a new name.
|
BoxSharedLink |
createSharedLink(BoxSharedLink.Access access,
Date unshareDate,
BoxSharedLink.Permissions permissions)
Creates a new shared link for this item.
|
void |
delete()
Deletes this file by moving it to the trash.
|
void |
download(OutputStream output)
Downloads the contents of this file to a given OutputStream.
|
void |
download(OutputStream output,
ProgressListener listener)
Downloads the contents of this file to a given OutputStream while reporting the progress to a ProgressListener.
|
void |
downloadRange(OutputStream output,
long offset)
Downloads a part of this file's contents, starting at specified byte offset.
|
void |
downloadRange(OutputStream output,
long rangeStart,
long rangeEnd)
Downloads a part of this file's contents, starting at rangeStart and stopping at rangeEnd.
|
void |
downloadRange(OutputStream output,
long rangeStart,
long rangeEnd,
ProgressListener listener)
Downloads a part of this file's contents, starting at rangeStart and stopping at rangeEnd, while reporting the
progress to a ProgressListener.
|
List<BoxComment.Info> |
getComments()
Gets a list of any comments on this file.
|
BoxFile.Info |
getInfo()
Gets information about this item.
|
BoxFile.Info |
getInfo(String... fields)
Gets information about this item that's limited to a list of specified fields.
|
Collection<BoxFileVersion> |
getVersions()
Gets any previous versions of this file.
|
void |
rename(String newName)
Renames this file.
|
void |
updateInfo(BoxFile.Info info)
Updates the information about this file with any info fields that have been modified locally.
|
void |
uploadVersion(InputStream fileContent)
Uploads a new version of this file, replacing the current version.
|
void |
uploadVersion(InputStream fileContent,
Date modified)
Uploads a new version of this file, replacing the current version.
|
void |
uploadVersion(InputStream fileContent,
Date modified,
long fileSize,
ProgressListener listener)
Uploads a new version of this file, replacing the current version, while reporting the progress to a
ProgressListener.
|
equals, getAPI, getID, hashCode
public static final String[] ALL_FIELDS
getInfo()
.public BoxFile(BoxAPIConnection api, String id)
api
- the API connection to be used by the file.id
- the ID of the file.public BoxSharedLink createSharedLink(BoxSharedLink.Access access, Date unshareDate, BoxSharedLink.Permissions permissions)
BoxItem
This method is a convenience method for manually creating a new shared link and applying it to this item with
BoxItem.Info.setSharedLink(com.box.sdk.BoxSharedLink)
. You may want to create the shared link manually so that it can be updated along with
other changes to the item's info in a single network request, giving a boost to performance.
createSharedLink
in class BoxItem
access
- the access level of the shared link.unshareDate
- the date and time at which the link will expire. Can be null to create a non-expiring link.permissions
- the permissions of the shared link. Can be null to use the default permissions.public BoxComment.Info addComment(String message)
message
- the comment's message.public void download(OutputStream output)
output
- the stream to where the file will be written.public void download(OutputStream output, ProgressListener listener)
output
- the stream to where the file will be written.listener
- a listener for monitoring the download's progress.public void downloadRange(OutputStream output, long offset)
output
- the stream to where the file will be written.offset
- the byte offset at which to start the download.public void downloadRange(OutputStream output, long rangeStart, long rangeEnd)
output
- the stream to where the file will be written.rangeStart
- the byte offset at which to start the download.rangeEnd
- the byte offset at which to stop the download.public void downloadRange(OutputStream output, long rangeStart, long rangeEnd, ProgressListener listener)
output
- the stream to where the file will be written.rangeStart
- the byte offset at which to start the download.rangeEnd
- the byte offset at which to stop the download.listener
- a listener for monitoring the download's progress.public BoxFile.Info copy(BoxFolder destination)
BoxItem
public BoxFile.Info copy(BoxFolder destination, String newName)
BoxItem
public void delete()
public void rename(String newName)
newName
- the new name of the file.public BoxFile.Info getInfo()
BoxItem
public BoxFile.Info getInfo(String... fields)
BoxItem
public void updateInfo(BoxFile.Info info)
The only fields that will be updated are the ones that have been modified locally. For example, the following code won't update any information (or even send a network request) since none of the info's fields were changed:
BoxFile file = new File(api, id); BoxFile.Info info = file.getInfo(); file.updateInfo(info);
info
- the updated info.public Collection<BoxFileVersion> getVersions()
public void uploadVersion(InputStream fileContent)
fileContent
- a stream containing the new file contents.public void uploadVersion(InputStream fileContent, Date modified)
fileContent
- a stream containing the new file contents.modified
- the date that the new version was modified.public void uploadVersion(InputStream fileContent, Date modified, long fileSize, ProgressListener listener)
fileContent
- a stream containing the new file contents.modified
- the date that the new version was modified.fileSize
- the size of the file used for determining the progress of the upload.listener
- a listener for monitoring the upload's progress.public List<BoxComment.Info> getComments()