C# Class Box.V2.Managers.BoxFilesManager

File objects represent that metadata about individual files in Box, with attributes describing who created the file, when it was last modified, and other information.
Inheritance: BoxResourceManager
Show file Open project: box/box-windows-sdk-v2 Class Usage Examples

Public Methods

Method Description
ApplyWatermarkAsync ( string id, BoxApplyWatermarkRequest applyWatermarkRequest = null ) : Task

Used to apply or update the watermark for a corresponding Box file.

BoxFilesManager ( IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool suppressNotifications = null ) : Box.V2.Auth
CopyAsync ( Box.V2.Models.BoxFileRequest fileRequest, List fields = null ) : Task

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

CreateSharedLinkAsync ( string id, Box.V2.Models.BoxSharedLinkRequest sharedLinkRequest, List fields = null ) : Task

Used to create a shared link for this particular file. Please see here for more information on the permissions available for shared links.

DeleteAsync ( string id, string etag = null ) : Task

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 immediately and permanently deleted from Box or moved to the trash.

DeleteOldVersionAsync ( string id, string versionId, string etag = null ) : Task

Discards a specific file version to the trash.

DeleteSharedLinkAsync ( string id ) : Task

Used to delete the shared link for this particular file.

DownloadStreamAsync ( string id, string versionId = null, System.TimeSpan timeout = null ) : Task

Returns the stream of the requested file.

GetCommentsAsync ( string id, List fields = null ) : Task>

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

GetDownloadUriAsync ( string id, string versionId = null ) : Task

Retrieves the temporary direct Uri to a file (valid for 15 minutes). This is typically used to send as a redirect to a browser to make the browser download the file directly from Box.

GetFileTasks ( string id, List fields = null ) : Task>

Retrieves all of the tasks for given file.

GetInformationAsync ( string id, List fields = null ) : Task

Retrieves information about a file.

GetLockAsync ( string id ) : Task

Gets a lock file object representation of the lock on the provided file Id (if a lock exists, otherwise returns null).

GetPreviewLinkAsync ( string id ) : Task

Gets a preview link (URI) for a file that is valid for 60 seconds.

GetThumbnailAsync ( string id, int minHeight = null, int minWidth = null, int maxHeight = null, int maxWidth = null, bool throttle = true, bool handleRetry = true ) : Task

Retrieves a thumbnail, or smaller image representation, of this file. Sizes of 32x32, 64x64, 128x128, and 256x256 can be returned in the .png format and sizes of 32x32, 94x94, 160x160, and 320x320 can be returned in the .jpg format. Thumbnails can be generated for the image and video file formats listed here. http://community.box.com/t5/Managing-Your-Content/What-file-types-are-supported-by-Box-s-Content-Preview/ta-p/327

GetTrashedAsync ( string id, List fields = null ) : Task

Retrieves an item that has been moved to the trash.

GetWatermarkAsync ( string id ) : Task

Used to retrieve the watermark for a corresponding Box file.

LockAsync ( BoxFileLockRequest lockFileRequest, string id ) : Task

Used to create a lock on the file.

PreflightCheck ( Box.V2.Models.BoxPreflightCheckRequest preflightCheckRequest ) : Task

Verify that a file will be accepted by Box before you send all the bytes over the wire.

Preflight checks verify all permissions as if the file was actually uploaded including: Folder upload permission File name collisions file size caps folder and file name restrictions* folder and account storage quota

PreflightCheckNewVersion ( string fileId, Box.V2.Models.BoxPreflightCheckRequest preflightCheckRequest ) : Task

Verify that a new version of a file will be accepted by Box before you send all the bytes over the wire.

PromoteVersionAsync ( string id, string versionId ) : Task

If there are previous versions of this file, this method can be used to promote one of the older versions to the top of the stack. This actually mints a copy of the old version and puts it on the top of the versions stack. The file will have the exact same contents, the same SHA1/etag, and the same name as the promoted version. Other properties such as comments do not get updated to their former values.

PurgeTrashedAsync ( string id ) : Task

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

RemoveWatermarkAsync ( string id ) : Task

Used to remove the watermark for a corresponding Box file.

RestoreTrashedAsync ( Box.V2.Models.BoxFileRequest fileRequest, List fields = null ) : Task

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.

UnLock ( string id ) : Task

Remove a lock

UpdateInformationAsync ( Box.V2.Models.BoxFileRequest fileRequest, string etag = null, List fields = null ) : Task

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 included to ensure that client only updates the file if it knows about the latest version.

UpdateLockAsync ( BoxFileLockRequest lockFileRequest, string id ) : Task

Used to update the lock information on the file (for example, ExpiresAt or IsDownloadPrevented.

UploadAsync ( Box.V2.Models.BoxFileRequest fileRequest, Stream stream, List fields = null, System.TimeSpan timeout = null, byte contentMD5 = null, bool setStreamPositionToZero = true, Uri uploadUri = null ) : Task

Uploads a provided file to the target parent folder. If the file already exists, an error will be thrown. A proper timeout should be provided for large uploads.

UploadNewVersionAsync ( string fileName, string fileId, Stream stream, string etag = null, List fields = null, System.TimeSpan timeout = null, byte contentMD5 = null, bool setStreamPositionToZero = true, Uri uploadUri = null ) : Task

This method is used to upload a new version of an existing file in a user’s account. Similar to regular file uploads, these are performed as multipart form uploads. An optional If-Match header can be included to ensure that client only overwrites the file if it knows about the latest version. The filename on Box will remain the same as the previous version. To update the file’s name, you can specify a new name for the file using the fileName parameter. A proper timeout should be provided for large uploads.

ViewVersionsAsync ( string id, List fields = null ) : Task>

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

Private Methods

Method Description
GetFilePreviewAsync ( string id, int page, int maxWidth = null, int minWidth = null, int maxHeight = null, int minHeight = null, bool handleRetry = true ) : Task
GetPreviewAsync ( string id, int page, bool handleRetry = true ) : Task
GetPreviewResponseAsync ( string id, int page, int maxWidth = null, int minWidth = null, int maxHeight = null, int minHeight = null, bool handleRetry = true ) : Task>
GetTimeDelay ( HttpResponseHeaders headers ) : int

Return the time to wait until retrying the call. If no RetryAfter value is specified in the header, use default value;

HexStringFromBytes ( byte bytes ) : string

Method Details

ApplyWatermarkAsync() public method

Used to apply or update the watermark for a corresponding Box file.
public ApplyWatermarkAsync ( string id, BoxApplyWatermarkRequest applyWatermarkRequest = null ) : Task
id string Id of the file.
applyWatermarkRequest Box.V2.Models.BoxApplyWatermarkRequest BoxApplyWatermarkRequest object. Can be null, for using default values - imprint="default"
return Task

BoxFilesManager() public method

public BoxFilesManager ( IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool suppressNotifications = null ) : Box.V2.Auth
config IBoxConfig
service IBoxService
converter IBoxConverter
auth IAuthRepository
asUser string
suppressNotifications bool
return Box.V2.Auth

CopyAsync() public method

Used to create a copy of a file in another folder. The original version of the file will not be altered.
public CopyAsync ( Box.V2.Models.BoxFileRequest fileRequest, List fields = null ) : Task
fileRequest Box.V2.Models.BoxFileRequest BoxFileRequest object.
fields List Attribute(s) to include in the response.
return Task

CreateSharedLinkAsync() public method

Used to create a shared link for this particular file. Please see here for more information on the permissions available for shared links.
public CreateSharedLinkAsync ( string id, Box.V2.Models.BoxSharedLinkRequest sharedLinkRequest, List fields = null ) : Task
id string Id of the file.
sharedLinkRequest Box.V2.Models.BoxSharedLinkRequest BoxSharedLinkRequest object.
fields List Attribute(s) to include in the response.
return Task

DeleteAsync() public method

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 immediately and permanently deleted from Box or moved to the trash.
public DeleteAsync ( string id, string etag = null ) : Task
id string Id of the file.
etag string This ‘etag’ field of the file, which will be set in the If-Match header.
return Task

DeleteOldVersionAsync() public method

Discards a specific file version to the trash.
public DeleteOldVersionAsync ( string id, string versionId, string etag = null ) : Task
id string Id of the file (Required).
versionId string Id of the version (Required).
etag string The etag of the file. This is in the ‘etag’ field of the file object.
return Task

DeleteSharedLinkAsync() public method

Used to delete the shared link for this particular file.
public DeleteSharedLinkAsync ( string id ) : Task
id string
return Task

DownloadStreamAsync() public method

Returns the stream of the requested file.
public DownloadStreamAsync ( string id, string versionId = null, System.TimeSpan timeout = null ) : Task
id string Id of the file to download.
versionId string The ID specific version of this file to download.
timeout System.TimeSpan Optional timeout for response.
return Task

GetCommentsAsync() public method

Retrieves the comments on a particular file, if any exist.
public GetCommentsAsync ( string id, List fields = null ) : Task>
id string The Id of the item that the comments should be retrieved for.
fields List Attribute(s) to include in the response.
return Task>

GetDownloadUriAsync() public method

Retrieves the temporary direct Uri to a file (valid for 15 minutes). This is typically used to send as a redirect to a browser to make the browser download the file directly from Box.
public GetDownloadUriAsync ( string id, string versionId = null ) : Task
id string Id of the file.
versionId string Version of the file.
return Task

GetFileTasks() public method

Retrieves all of the tasks for given file.
public GetFileTasks ( string id, List fields = null ) : Task>
id string Id of the file.
fields List Attribute(s) to include in the response.
return Task>

GetInformationAsync() public method

Retrieves information about a file.
public GetInformationAsync ( string id, List fields = null ) : Task
id string Id of the file.
fields List Attribute(s) to include in the response.
return Task

GetLockAsync() public method

Gets a lock file object representation of the lock on the provided file Id (if a lock exists, otherwise returns null).
public GetLockAsync ( string id ) : Task
id string Id of the file.
return Task

GetPreviewLinkAsync() public method

Gets a preview link (URI) for a file that is valid for 60 seconds.
public GetPreviewLinkAsync ( string id ) : Task
id string Id of the file.
return Task

GetThumbnailAsync() public method

Retrieves a thumbnail, or smaller image representation, of this file. Sizes of 32x32, 64x64, 128x128, and 256x256 can be returned in the .png format and sizes of 32x32, 94x94, 160x160, and 320x320 can be returned in the .jpg format. Thumbnails can be generated for the image and video file formats listed here. http://community.box.com/t5/Managing-Your-Content/What-file-types-are-supported-by-Box-s-Content-Preview/ta-p/327
public GetThumbnailAsync ( string id, int minHeight = null, int minWidth = null, int maxHeight = null, int maxWidth = null, bool throttle = true, bool handleRetry = true ) : Task
id string Id of the file.
minHeight int The minimum height of the thumbnail.
minWidth int The minimum width of the thumbnail.
maxHeight int The maximum height of the thumbnail.
maxWidth int The maximum width of the thumbnail.
throttle bool Whether the requests will be throttled. Recommended to be left true to prevent spamming the server.
handleRetry bool Specifies whether the method handles retries. If true, then the method would retry the call if the HTTP response is 'Accepted'. The delay for the retry is determined /// by the RetryAfter header, or if that header is not set, by the constant DefaultRetryDelay.
return Task

GetTrashedAsync() public method

Retrieves an item that has been moved to the trash.
public GetTrashedAsync ( string id, List fields = null ) : Task
id string Id of the file.
fields List Attribute(s) to include in the response.
return Task

GetWatermarkAsync() public method

Used to retrieve the watermark for a corresponding Box file.
public GetWatermarkAsync ( string id ) : Task
id string Id of the file.
return Task

LockAsync() public method

Used to create a lock on the file.
public LockAsync ( BoxFileLockRequest lockFileRequest, string id ) : Task
lockFileRequest Box.V2.Models.BoxFileLockRequest Request contains Lock object for setting of lock properties such as ExpiresAt - the time the lock expires, IsDownloadPrevented - whether or not the file can be downloaded while locked.
id string Id of the file.
return Task

PreflightCheck() public method

Verify that a file will be accepted by Box before you send all the bytes over the wire.
Preflight checks verify all permissions as if the file was actually uploaded including: Folder upload permission File name collisions file size caps folder and file name restrictions* folder and account storage quota
public PreflightCheck ( Box.V2.Models.BoxPreflightCheckRequest preflightCheckRequest ) : Task
preflightCheckRequest Box.V2.Models.BoxPreflightCheckRequest BoxPreflightCheckRequest object.
return Task

PreflightCheckNewVersion() public method

Verify that a new version of a file will be accepted by Box before you send all the bytes over the wire.
public PreflightCheckNewVersion ( string fileId, Box.V2.Models.BoxPreflightCheckRequest preflightCheckRequest ) : Task
fileId string
preflightCheckRequest Box.V2.Models.BoxPreflightCheckRequest
return Task

PromoteVersionAsync() public method

If there are previous versions of this file, this method can be used to promote one of the older versions to the top of the stack. This actually mints a copy of the old version and puts it on the top of the versions stack. The file will have the exact same contents, the same SHA1/etag, and the same name as the promoted version. Other properties such as comments do not get updated to their former values.
public PromoteVersionAsync ( string id, string versionId ) : Task
id string Id of the file (Required).
versionId string Id of the version (Required).
return Task

PurgeTrashedAsync() public method

Permanently deletes an item that is in the trash. The item will no longer exist in Box. This action cannot be undone.
public PurgeTrashedAsync ( string id ) : Task
id string Id of the file.
return Task

RemoveWatermarkAsync() public method

Used to remove the watermark for a corresponding Box file.
public RemoveWatermarkAsync ( string id ) : Task
id string Id of the file.
return Task

RestoreTrashedAsync() public method

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.
public RestoreTrashedAsync ( Box.V2.Models.BoxFileRequest fileRequest, List fields = null ) : Task
fileRequest Box.V2.Models.BoxFileRequest BoxFileRequest object.
fields List Attribute(s) to include in the response.
return Task

UnLock() public method

Remove a lock
public UnLock ( string id ) : Task
id string
return Task

UpdateInformationAsync() public method

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 included to ensure that client only updates the file if it knows about the latest version.
public UpdateInformationAsync ( Box.V2.Models.BoxFileRequest fileRequest, string etag = null, List fields = null ) : Task
fileRequest Box.V2.Models.BoxFileRequest BoxFileRequest object.
etag string This ‘etag’ field of the file, which will be set in the If-Match header.
fields List Attribute(s) to include in the response.
return Task

UpdateLockAsync() public method

Used to update the lock information on the file (for example, ExpiresAt or IsDownloadPrevented.
public UpdateLockAsync ( BoxFileLockRequest lockFileRequest, string id ) : Task
lockFileRequest Box.V2.Models.BoxFileLockRequest BoxFileLockRequest object.
id string Id of the file.
return Task

UploadAsync() public method

Uploads a provided file to the target parent folder. If the file already exists, an error will be thrown. A proper timeout should be provided for large uploads.
public UploadAsync ( Box.V2.Models.BoxFileRequest fileRequest, Stream stream, List fields = null, System.TimeSpan timeout = null, byte contentMD5 = null, bool setStreamPositionToZero = true, Uri uploadUri = null ) : Task
fileRequest Box.V2.Models.BoxFileRequest BoxFileRequest object.
stream Stream Stream of uploading file.
fields List Fields which shall be returned in result.
timeout System.TimeSpan Timeout for response.
contentMD5 byte The SHA1 hash of the file.
setStreamPositionToZero bool Set position for input stream to 0.
uploadUri System.Uri Uri to use for upload. Default upload endpoint URI is used if not specified.
return Task

UploadNewVersionAsync() public method

This method is used to upload a new version of an existing file in a user’s account. Similar to regular file uploads, these are performed as multipart form uploads. An optional If-Match header can be included to ensure that client only overwrites the file if it knows about the latest version. The filename on Box will remain the same as the previous version. To update the file’s name, you can specify a new name for the file using the fileName parameter. A proper timeout should be provided for large uploads.
public UploadNewVersionAsync ( string fileName, string fileId, Stream stream, string etag = null, List fields = null, System.TimeSpan timeout = null, byte contentMD5 = null, bool setStreamPositionToZero = true, Uri uploadUri = null ) : Task
fileName string Name of the file.
fileId string Id of the file to upload a new version to.
stream Stream Stream of the uploading file.
etag string This ‘etag’ field of the file, which will be set in the If-Match header.
fields List Fields which shall be returned in result.
timeout System.TimeSpan Optional timeout for response.
contentMD5 byte The SHA1 hash of the file.
setStreamPositionToZero bool Set position for input stream to 0.
uploadUri System.Uri Optional url for uploading file.
return Task

ViewVersionsAsync() public method

If there are previous versions of this file, this method can be used to retrieve metadata about the older versions. Versions are only tracked for Box users with premium accounts.
public ViewVersionsAsync ( string id, List fields = null ) : Task>
id string The file id.
fields List Attribute(s) to include in the response.
return Task>