public class

BoxConnector

extends Object
java.lang.Object
   ↳ org.mule.modules.box.BoxConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Box Cloud Connector for API V2.

Summary

Fields
private String accessToken
private String accessTokenIdentifier
private WebResource apiResource
private String baseUrl The api's base url
private Client client
private String clientId The OAuth2 client id
private String clientSecret The OAuth2 client secret
private JerseyUtil jerseyUtil
private LongPollingClient longPollingClient
private static List<SourceCallback> pendingSubscriptions This list holds the source callbacks for long polling that can't yet be served because authorization hasn't happened
private WebResource uploadResource
private String uploadUrl The url of the endpoints dedicated to file uploading operations
private boolean useGzip If set to true, Box will be asked to gzip all its responses
Public Constructors
BoxConnector()
Public Methods
User changePrimaryLogin(String userId, String login)
Used to convert one of the user’s confirmed email aliases into the user’s primary login.
Comment commentDiscussion(String discussionId, String message)
Used to add a comment to a discussion.
Comment commentFile(String fileId, String message)
Used to add a comment by the user to a specific file
File copyFile(String targetFolderId, String fileId)
Used to create a copy of a file in another folder.
Folder copyFolder(String targetFolderId, String folderId)
Used to create a shared link for this particular folder
Collaboration createCollaboration(Collaboration collaboration)
Used to add a collaboration for a single user to a folder.
Discussion createDiscussion(Discussion discussion)
Used to create the metadata for a new discussion for a particular folder.
EmailAlias createEmailAlias(String userId, String email)
Adds a new email alias to the given user’s account.
Folder createFolder(String parentId, String folderName)
Creates a new folder and returns a folder object with all its associated information
User createUser(User user)
Used to provision a new user in an enterprise.
void deleteCollaboration(String collaborationId)
Used to delete a single collaboration.
void deleteComment(String commentId)
Delets a comment.
void deleteEmailAlias(String userId, String emailAliasId)
Removes an email alias from a user.
void deleteFile(String fileId, String etag)
Discards a file to the trash.
void deleteFolder(String folderId, Boolean recursive)
Deletes a folder
void deleteUser(String userId, Boolean notify, Boolean force)
Deletes a user in an enterprise account.
InputStream download(String fileId, String version)
Downloads a file
String getAccessToken()
String getBaseUrl()
String getClientId()
String getClientSecret()
Collaboration getCollaboration(String collaborationId)
Used to get information about a single collaboration.
Comment getComment(String commentId)
Used to retrieve the message and metadata about a specific comment.
Discussion getDiscussion(String discussionId)
Used to retrieve the metadata about a specific discussion.
GetCommentsResponse getDiscussionComments(String discussionId)
Used to retrieve all comments for a given discussion.
GetEmailAliasResponse getEmailAliases(String userId)
Retrieves all email aliases for this user.
GetEventsResponse getEnterpriseEvents(String createdAfter, String createdBefore, List<String> eventTypes, Long limit, Long offset)
Retrieves events for all users in an enterprise.
GetEventsResponse getEvents(String streamPosition, StreamType streamType, Long limit)
Use this to get events for a given user.
LongPollingServer getEventsLongPollingServer()
Requests access to a long polling server that notifies about events in real time.
GetCommentsResponse getFileComments(String fileId)
Retrieves the comments on a particular file, if any exist.
File getFileMetadata(String fileId)
Used to retrieve the metadata about a file.
InputStream getFileThumbnail(String fileId, ThumbnailSize minSize, ThumbnailSize maxSize)
Retrieves a thumbnail, or smaller image representation, of this file.
Folder getFolder(String folderId)
Retrieves information about a given folder.
Folder getFolderByPath(String resourcePath)
Returns the folder information for a given path
Entries getFolderDiscussions(String folderId)
Retrieves the discussions on a particular folder, if any exist.
Item getFolderItem(String folderId, String resourceName)
Traverses a given folder looking for a resource (file or folder) of a given name.
GetItemsResponse getFolderItems(String folderId, Long limit, Long offset)
Retrieves the files and/or folders contained within this folder without any other metadata about the folder in the mini format is returned for each item by default.
Item getItemByPath(String resourcePath)
Returns the item information for a given path.
String getOAuthTokenAccessIdentifier()
GetCollaborationsResponse getPendingCollaborations()
Used to retrieve all pending collaboration invites for this user.
File getTrashedFile(String fileId)
Retrieves the metadata of a trashed file
Folder getTrashedFolder(String folderId)
Retrieves a folder that has been moved to the trash.
GetItemsResponse getTrashedItems(Long limit, Long offset)
Get the folders in the Trash.
String getUploadUrl()
boolean getUseGzip()
User getUser()
Retrieves information about the user who is currently logged in i.e.
GetUsersResponse getUsers(String filterTerm, Long limit, Long offset)
Returns a list of all users for the Enterprise
FileVersionResponse getVersionsMetadata(String fileId)
If there are previous versions of this file, this method can be used to retrieve metadata about the older versions.
void init()
This method initiaes the box client and the auth callback.
synchronized StopSourceCallback listenEvents(SourceCallback callback)
Message source that subscribes to the events long polling server and will trigger a new message each time an event is generated.
Folder moveFolderToUser(User targetUser, String folderId, Boolean notify)
Moves all of the content from within one user’s folder into a new folder in another user’s account.
void permDeleteFile(String fileId)
Permanently deletes an item that is in the trash.
void permDeleteFolder(String folderId)
Permanently deletes an item that is in the trash.
void postAuth()
File restoreTrashedFile(String fileId, RestoreTrashedItemRequest request)
Restores a file that has been moved to the trash.
Folder restoreTrashedFolder(String folderId, RestoreTrashedItemRequest request)
Restores an item that has been moved to the trash.
SearchResponse search(String query, Long limit, Long offset)
The search endpoint provides a simple way of finding items that are accessible in a given user’s Box account.
void setAccessToken(String accessToken)
void setBaseUrl(String baseUrl)
void setClientId(String clientId)
void setClientSecret(String clientSecret)
void setUploadUrl(String uploadUrl)
void setUseGzip(boolean useGzip)
File shareFile(String fileId, SharedLink sharedLink)
Used to create a shared link for this particular file.
Folder shareFolder(String folderId, SharedLink sharedLink)
Used to create a shared link for this particular folder
File unshareFile(String fileId)
Deletes the shared link associated to a file
Folder unshareFolder(String folderId)
Deletes the shared link associated to a folder
Collaboration updateCollaboration(Collaboration collaboration, String collaborationId)
Used to update an existing collaboration.
Comment updateComment(String commentId, String newMessage)
Used to update the message of the comment.
Discussion updateDiscussion(Discussion discussion, String discussionId)
Used to update the metadata for an existing discussion.
File updateFile(String fileId, UpdateItemRequest request, String etag)
Update a file’s information.
Folder updateFolder(UpdateItemRequest request, String folderId, String etag)
Used to update information about the folder.
User updateUser(String userId, User user, Boolean notify)
Used to edit the settings and information about a user.
File uploadNewVersionPath(String path, String fileId, String filename, String etag, String contentModifiedAt)
Uploads a new version of a file by reading the contents from a path in local storage
File uploadNewVersionStream(InputStream content, String fileId, String etag, String filename, String contentModifiedAt)
Uploads a new version of a file from an input stream
File uploadPath(String path, String folderId, String filename, boolean includeHash, String contentCreatedAt, String contentModifiedAt)
Receives the path of a file in local storage and uploads its content
File uploadStream(String folderId, String filename, InputStream content, boolean includeHash, String contentCreatedAt, String contentModifiedAt)
Creates a new file with the contents of a java.io.InputStream.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private String accessToken

private String accessTokenIdentifier

private WebResource apiResource

private String baseUrl

The api's base url

private Client client

private String clientId

The OAuth2 client id

private String clientSecret

The OAuth2 client secret

private JerseyUtil jerseyUtil

private LongPollingClient longPollingClient

private static List<SourceCallback> pendingSubscriptions

This list holds the source callbacks for long polling that can't yet be served because authorization hasn't happened

private WebResource uploadResource

private String uploadUrl

The url of the endpoints dedicated to file uploading operations

private boolean useGzip

If set to true, Box will be asked to gzip all its responses

Public Constructors

public BoxConnector ()

Public Methods

public User changePrimaryLogin (String userId, String login)

Used to convert one of the user’s confirmed email aliases into the user’s primary login.

Parameters
userId The id of the user being updated
login The new login
Returns
  • an instance of User with the modified state

public Comment commentDiscussion (String discussionId, String message)

Used to add a comment to a discussion.

Parameters
discussionId The id of the discussion to comment on
message The text of the comment to be posted
Returns
  • an instance of Comment representing the created message

public Comment commentFile (String fileId, String message)

Used to add a comment by the user to a specific file

Parameters
fileId The id of the file to be commented on
message Text of the comment to be posted
Returns
  • an instance of Comment representing the created message

public File copyFile (String targetFolderId, String fileId)

Used to create a copy of a file in another folder. The original version of the file will not be altered.

Parameters
targetFolderId The if of the target folder. Defaults to the root folder
fileId The id of the file you want to copy
Returns
  • and instance of File representing the copy of the file

public Folder copyFolder (String targetFolderId, String folderId)

Used to create a shared link for this particular folder

Parameters
targetFolderId The id of the parent folder that will hold the copy. If not provided then the root will be used
folderId The if od the folder being copied
Returns
  • an instance of Folder representing the copy

public Collaboration createCollaboration (Collaboration collaboration)

Used to add a collaboration for a single user to a folder. Either an email address or a user ID can be used to create the collaboration. Transferring ownership: To transfer ownership of a folder (as the current owner of the folder), first create a collaboration for the new user with any role. Then update that collaboration with a role of ‘owner’.

Parameters
collaboration Object representing the collaboration to be created
Returns
  • a new instance of Collaboration with the state of the newly created collab

public Discussion createDiscussion (Discussion discussion)

Used to create the metadata for a new discussion for a particular folder. The parent, id and name attributes of the request object are required

Parameters
discussion The discussion object to be created
Returns
  • an instance of Discussion with the metadata of the created discussion

public EmailAlias createEmailAlias (String userId, String email)

Adds a new email alias to the given user’s account.

Parameters
userId The id of the user getting the alias
email The new email alias
Returns

public Folder createFolder (String parentId, String folderName)

Creates a new folder and returns a folder object with all its associated information

Parameters
parentId The id of the parent folder. If not provided then the root will be used
folderName The name of the folder
Returns
  • an instance of Folder representing the newly created folder

public User createUser (User user)

Used to provision a new user in an enterprise. This method only works for enterprise admins.

Parameters
user An instance of User representing the user to be created
Returns
  • a new instance of User with the final state of the created object

public void deleteCollaboration (String collaborationId)

Used to delete a single collaboration.

Parameters
collaborationId The id of the collaboration to be deleted

public void deleteComment (String commentId)

Delets a comment.

Parameters
commentId The id of the comment to be deleted

public void deleteEmailAlias (String userId, String emailAliasId)

Removes an email alias from a user.

Parameters
userId The id of the user owning the alias
emailAliasId The id of the alias being deleted

public void deleteFile (String fileId, String etag)

Discards a file to the trash. The etag of the file can be included as an ‘If-Match’ header to prevent race conditions. Depending on the enterprise settings for this user, the item will either be actually deleted from Box or moved to the trash.

Parameters
fileId The id of the file to be deleted
etag If provided, it will be used to verify that no newer version of the file is available at box

public void deleteFolder (String folderId, Boolean recursive)

Deletes a folder

Parameters
folderId The id of the folder to be deleted
recursive Whether to delete this folder if it has items inside of it

public void deleteUser (String userId, Boolean notify, Boolean force)

Deletes a user in an enterprise account.

Parameters
userId The id of the user being delete
notify Determines if the destination user should receive email notification of the transfer.
force Whether or not the user should be deleted even if this user still own files.

public InputStream download (String fileId, String version)

Downloads a file

Parameters
fileId The id of the file you want
version The ID specific version of this file to download.
Returns
  • an input stream with the contents of the file

public String getAccessToken ()

public String getBaseUrl ()

public String getClientId ()

public String getClientSecret ()

public Collaboration getCollaboration (String collaborationId)

Used to get information about a single collaboration.

Parameters
collaborationId The id of the collaboration you want
Returns

public Comment getComment (String commentId)

Used to retrieve the message and metadata about a specific comment. Information about the user who created the comment is also included.

Parameters
commentId The id of the comment you want
Returns
  • an instance of Comment representing the message

public Discussion getDiscussion (String discussionId)

Used to retrieve the metadata about a specific discussion. Information about the user who created the discussion is also included.

Parameters
discussionId The id of the discussion you wnat
Returns
  • an instance of Discussion with the discussion metadata

public GetCommentsResponse getDiscussionComments (String discussionId)

Used to retrieve all comments for a given discussion.

Parameters
discussionId The id of the discussions which comments you want
Returns

public GetEmailAliasResponse getEmailAliases (String userId)

Retrieves all email aliases for this user. The collection of email aliases does not include the primary login for the user

Parameters
userId The id of the user whose aliases you want
Returns

public GetEventsResponse getEnterpriseEvents (String createdAfter, String createdBefore, List<String> eventTypes, Long limit, Long offset)

Retrieves events for all users in an enterprise. Upper and lower bounds as well as filters can be applied to the results.

Parameters
createdAfter A lower bound on the timestamp of the events returned
createdBefore An upper bound on the timestamp of the events returned
eventTypes List of events to filter by
limit Limits the number of events returned
offset The item at which to start
Returns

public GetEventsResponse getEvents (String streamPosition, StreamType streamType, Long limit)

Use this to get events for a given user. A chunk of event objects is returned for the user based on the parameters passed in. Parameters indicating how many chunks are left as well as the next streamPosition are also returned.

Parameters
streamPosition The location in the event stream at which you want to start receiving events. Can specify special case ‘now’ to get 0 events and the latest stream position for initialization.
streamType Limits the type of events returned
limit Limits the number of events returned
Returns

public LongPollingServer getEventsLongPollingServer ()

Requests access to a long polling server that notifies about events in real time. This is just a request for connection details. A subscription to such topic is not made

Returns

public GetCommentsResponse getFileComments (String fileId)

Retrieves the comments on a particular file, if any exist.

Parameters
fileId The id of the while which comments you want
Returns

public File getFileMetadata (String fileId)

Used to retrieve the metadata about a file.

Parameters
fileId The id of the file you want to inspect
Returns
  • an instance of File

public InputStream getFileThumbnail (String fileId, ThumbnailSize minSize, ThumbnailSize maxSize)

Retrieves a thumbnail, or smaller image representation, of this file. Sizes of 32x32, 64x64, 128x128, and 256x256 can be returned. Currently thumbnails are only available in .png format and will only be generated for image file formats.

Parameters
fileId The id of the file which thumb you want
minSize The minimum size you're interested in
maxSize The maximum size you're interested in
Returns
  • an InputStream with the content of the thumb. Remember to close it!

public Folder getFolder (String folderId)

Retrieves information about a given folder. If the folderId parameter is not provided or equals 0, then the root folder will be returned.

Parameters
folderId The id of the fodler you want to get. 0 means root
Returns

public Folder getFolderByPath (String resourcePath)

Returns the folder information for a given path

Parameters
resourcePath The resource to retrieve from Box
Returns
  • an instance of Folder with that about the found Folder. null if the folder is not found

public Entries getFolderDiscussions (String folderId)

Retrieves the discussions on a particular folder, if any exist.

Parameters
folderId The id of the folder which discussions you want
Returns

public Item getFolderItem (String folderId, String resourceName)

Traverses a given folder looking for a resource (file or folder) of a given name.

Parameters
folderId The id of the folder you want to inspect. If not provided then the root folder is assumed
resourceName The name you want to test
Returns
  • an instance of Item with that about the found item. null if the item is not found

public GetItemsResponse getFolderItems (String folderId, Long limit, Long offset)

Retrieves the files and/or folders contained within this folder without any other metadata about the folder in the mini format is returned for each item by default. Paginated results can be retrieved using the limit and offset parameters.

Parameters
folderId The id of the folder you want to inspect. If not provided then the root folder is assumed
limit The maximum amount of items to be returned (default=100, max=1000)
offset Pagination offset (default=0)
Returns

public Item getItemByPath (String resourcePath)

Returns the item information for a given path.

Parameters
resourcePath The resource to retrieve from Box
Returns
  • an instance of Item with that about the found item. null if the item is not found

public String getOAuthTokenAccessIdentifier ()

public GetCollaborationsResponse getPendingCollaborations ()

Used to retrieve all pending collaboration invites for this user.

Returns

public File getTrashedFile (String fileId)

Retrieves the metadata of a trashed file

Parameters
fileId The id of the trashed file you want
Returns
  • an instance of File

public Folder getTrashedFolder (String folderId)

Retrieves a folder that has been moved to the trash.

Parameters
folderId The id of the folder you want
Returns

public GetItemsResponse getTrashedItems (Long limit, Long offset)

Get the folders in the Trash. Retrieves the files and/or folders that have been moved to the trash using the mini format. Paginated results can be retrieved using the limit and offset parameters.

Parameters
limit The maximum amount of items to be returned (default=100, max=1000)
offset Pagination offset (default=0)
Returns

public String getUploadUrl ()

public boolean getUseGzip ()

public User getUser ()

Retrieves information about the user who is currently logged in i.e. the user for whom this auth token was generated.

Returns
  • an instance of User

public GetUsersResponse getUsers (String filterTerm, Long limit, Long offset)

Returns a list of all users for the Enterprise

Parameters
filterTerm A string used to filter the results to only users starting with the filter_term in either the name or the login
limit The number of records to return.
offset The record at which to start
Returns

public FileVersionResponse getVersionsMetadata (String fileId)

If there are previous versions of this file, this method can be used to retrieve metadata about the older versions. Alert: Versions are only tracked for Box users with premium accounts.

Parameters
fileId The id of the file which versions you want to pull
Returns

public void init ()

This method initiaes the box client and the auth callback. Also, it fetches the save/restore flows (if specified). If those are specified but don't exist in the registry, then IllegalArgumentException is thrown

Throws
IllegalArgumentException if restore/save token flows are specified but don't exist
MuleException

public synchronized StopSourceCallback listenEvents (SourceCallback callback)

Message source that subscribes to the events long polling server and will trigger a new message each time an event is generated. Such message will have an instance of @{link org.mule.modules.box.model.PollingEvent} as payload and an inbound property called 'boxAccessTokenId' that will carry the accessTokenId of the user that owns the event. This source will not provide the events that are generated, it's just a notification that there're new events available. You'll need to use the get-events processor to actually get them. Managing the stream position while doing so is up to you.

Parameters
callback Callback to be invoked when a message arribes
Returns
  • an instance of org.mule.api.callback.StopSourceCallback that unsubscribes the long polling server when the app is stopped.

public Folder moveFolderToUser (User targetUser, String folderId, Boolean notify)

Moves all of the content from within one user’s folder into a new folder in another user’s account. You can move folders across users as long as the you have administrative permissions. To move everything from the root folder, use 0 (zero) which always represents the root folder of a Box account

Parameters
targetUser An instance of User representing the user that will receive the folder
folderId The id of the folder to be moved
notify Determines if the destination user should receive email notification of the transfer.
Returns
  • an instance of Folder representing the moved folder

public void permDeleteFile (String fileId)

Permanently deletes an item that is in the trash. The item will no longer exist in Box. This action cannot be undone.

Parameters
fileId The id of the file to be permanently deleted

public void permDeleteFolder (String folderId)

Permanently deletes an item that is in the trash. The item will no longer exist in Box. This action cannot be undone.

Parameters
folderId The id of the folder to be permanently deleted

public void postAuth ()

public File restoreTrashedFile (String fileId, RestoreTrashedItemRequest request)

Restores a file that has been moved to the trash. Default behavior is to restore the item to the folder it was in before it was moved to the trash. If that parent folder no longer exists or if there is now an item with the same name in that parent folder, the new parent folder and/or new name will need to be included in the request.

Parameters
fileId The id of the trashed file being restored
request An instance of RestoreTrashedItemRequest with the request parameters
Returns
  • an instance of Folder with the restored folder new state

public Folder restoreTrashedFolder (String folderId, RestoreTrashedItemRequest request)

Restores an item that has been moved to the trash. Default behavior is to restore the item to the folder it was in before it was moved to the trash. If that parent folder no longer exists or if there is now an item with the same name in that parent folder, the new parent folder and/or new name will need to be included in the request.

Parameters
folderId The id of the trashed folder being restored
request An instance of RestoreTrashedItemRequest with the request parameters
Returns
  • an instance of Folder with the restored folder new state

public SearchResponse search (String query, Long limit, Long offset)

The search endpoint provides a simple way of finding items that are accessible in a given user’s Box account.

Parameters
query The string to search for; can be matched against item names, descriptions, text content of a file, and other fields of the different item types.
limit Number of search results to return
offset The search result at which to start the response
Returns

public void setAccessToken (String accessToken)

Parameters
accessToken

public void setBaseUrl (String baseUrl)

Parameters
baseUrl

public void setClientId (String clientId)

Parameters
clientId

public void setClientSecret (String clientSecret)

Parameters
clientSecret

public void setUploadUrl (String uploadUrl)

Parameters
uploadUrl

public void setUseGzip (boolean useGzip)

Parameters
useGzip

public File shareFile (String fileId, SharedLink sharedLink)

Used to create a shared link for this particular file.

Parameters
fileId The id of the file you want to share
sharedLink An instance of SharedLink with the information about the share
Returns
  • an instance of File representing the shared folder

public Folder shareFolder (String folderId, SharedLink sharedLink)

Used to create a shared link for this particular folder

Parameters
folderId The id of the folder you want to share
sharedLink An instance of SharedLink with the information about the share
Returns
  • an instance of Folder representing the shared folder

public File unshareFile (String fileId)

Deletes the shared link associated to a file

Parameters
fileId The id of the file you want to unshare
Returns
  • an instance of File representing the unshared folder

public Folder unshareFolder (String folderId)

Deletes the shared link associated to a folder

Parameters
folderId The id of the folder you want to unshare
Returns
  • an instance of Folder representing the unshared folder

public Collaboration updateCollaboration (Collaboration collaboration, String collaborationId)

Used to update an existing collaboration.

Parameters
collaboration Object holding the new state for the collaboration
collaborationId The id of the collaboration to be updated
Returns

public Comment updateComment (String commentId, String newMessage)

Used to update the message of the comment.

Parameters
commentId The id of the comment to be updated
newMessage The new message
Returns
  • an instance of Comment representing the updated message

public Discussion updateDiscussion (Discussion discussion, String discussionId)

Used to update the metadata for an existing discussion.

Parameters
discussion Discussion object carrying the new state
discussionId The id of the discussion to be updated
Returns
  • a new instance of Discussion carrying the updated state

public File updateFile (String fileId, UpdateItemRequest request, String etag)

Update a file’s information. Used to update individual or multiple fields in the file object, including renaming the file, changing it’s description, and creating a shared link for the file. To move a file, change the ID of its parent folder. An optional etag can be provided to ensure that client only updates the file if it knows about the latest version

Parameters
fileId The id of the file which metadata you want to update
request An instance of UpdateItemRequest carrying the update parameters
etag If provided, it will be used to verify that no newer version of the file is available at box
Returns
  • an instance of File with the updated state of the file

public Folder updateFolder (UpdateItemRequest request, String folderId, String etag)

Used to update information about the folder. To move a folder, update the ID of its parent. To enable an email address that can be used to upload files to this folder, update the folderUploadEmail attribute. An optional If-Match header can be included to ensure that client only updates the folder if it knows about the latest version by setting the etag attribute.

Parameters
request An instance of UpdateItemRequest with the attributes you want to change
folderId The id of the folder to be modified
etag If provided, it will be used to verify that no newer version of the file is available at box
Returns
  • an instance of Folder that represents the updated folder

public User updateUser (String userId, User user, Boolean notify)

Used to edit the settings and information about a user. This method only works for enterprise admins. To roll a user out of the enterprise (and convert them to a standalone free user), update the special enterprise attribute to be null

Parameters
userId The id of the user you want to update
user The user object with the updated state
notify Whether the user should receive an email when they are rolled out of an enterprise
Returns
  • an instance of User with the updated user state

public File uploadNewVersionPath (String path, String fileId, String filename, String etag, String contentModifiedAt)

Uploads a new version of a file by reading the contents from a path in local storage

Parameters
path The path of the file in local storage
fileId The id of the file to be updated
filename New name for the file
etag If provided, it will be used to verify that no newer version of the file is available at box
contentModifiedAt The time this file was modified on the user’s machine. An example of a valid date is 2012-12-12T10:55:30-08:00
Returns
  • an instance of File with the information of the updated file

public File uploadNewVersionStream (InputStream content, String fileId, String etag, String filename, String contentModifiedAt)

Uploads a new version of a file from an input stream

Parameters
content A java.io.InputStream with the contents of the file. This stream will leave this processor in a closed state
fileId The id of the file to be updated
etag If provided, it will be used to verify that no newer version of the file is available at box
filename New name for the file
contentModifiedAt The time this file was modified on the user’s machine. An example of a valid date is 2012-12-12T10:55:30-08:00
Returns
  • an instance of File with the information of the updated file

public File uploadPath (String path, String folderId, String filename, boolean includeHash, String contentCreatedAt, String contentModifiedAt)

Receives the path of a file in local storage and uploads its content

Parameters
path The path of the file in local storage
folderId The id of the target folder.
filename The name you want the file to have at box. If not provided, the name on current storage will be used
includeHash If true a sha1 hash of the file will be calculated prior to upload. Box will use that hash to verify that the content's hasn't been corrupted.
contentCreatedAt The time this file was created on the user’s machine. An example of a valid date is 2012-12-12T10:55:30-08:00
contentModifiedAt The time this file was modified on the user’s machine. An example of a valid date is 2012-12-12T10:55:30-08:00
Returns
  • an instance of File with the information of the created file

public File uploadStream (String folderId, String filename, InputStream content, boolean includeHash, String contentCreatedAt, String contentModifiedAt)

Creates a new file with the contents of a java.io.InputStream. You need to take in count that since this is a stream, using the option of including a verification hash will cause the contents of the input stream to be fully read and loaded in memory.

Parameters
folderId The id of the target folder.
filename The name you want the file to have at box.
content A java.io.InputStream with the contents of the file. This stream will leave this processor in a closed state
includeHash If true a sha1 hash of the file will be calculated prior to upload. Box will use that hash to verify that the content's hasn't been corrupted.
contentCreatedAt The time this file was created on the user’s machine. An example of a valid date is 2012-12-12T10:55:30-08:00
contentModifiedAt The time this file was modified on the user’s machine. An example of a valid date is 2012-12-12T10:55:30-08:00
Returns
  • an instance of File with the information of the created file