Cloud Storage Integrator - Online Help
Cloud Storage Integrator
Questions / Feedback?

Box Component

Properties   Methods   Events   Configuration Settings   Errors  

The Box component provide an easy way to upload, download, and manage files and folders with Box.com.

Syntax

nsoftware.InCloudStorage.Box

Remarks

The Box component provides a simple interface to working with Box.com. Capabilities include uploading and downloading files, strong encryption support, creating folders, moving and copying resource, and more.

To begin, first create an account and register your application with Box.com. Consult the Box.com documentation for instructions on this process.

Authentication

Authentication is performed via OAuth 2.0. Use the OAuth component included in the toolkit, or any other OAuth implementation to perform authentication and retrieve an authorization string. Once you've obtained an authorization string like:

Bearer ya29.AHES6ZSZEJzATdZYjeihDn5W-VrXSsxEZu5p0pclxGdKKQ
Assign this value to the Authorization property before attempting any operations. Consult the Box.com documentation for this particular service for more information about supported scope values and more details on OAuth authentication.

Listing Resources

ListResources lists resources within the account at the specified path.

ListResources lists resources in the folder specified by ResourceParentId. If ResourceParentId is unspecified the root folder contents will be listed.

After calling this method set ResourceIndex to a value from 0 to ResourceCount - 1. Setting ResourceIndex populates other Resource properties to provide information about the resource.

After calling this method the following resource properties are populated:

If the results are paged, the ResourceMarker property will be populated. Call this method again to retrieve the next page of results. When the last page of results is returned ResourceMarker will be empty.

Note: To define a specific list of fields which are returned in the response for each resource set the "fields" parameter via AddQueryParam. Refer to the Box documentation for a full list of available fields.


box.ResourceParentId = "123456";
box.ListResources();
for (int i = 0; i < box.ResourceCount; i++)
{
  box.ResourceIndex = i;
  Console.WriteLine(box.ResourceName);
}

Downloading Files

The DownloadFile method downloads a specific file.

DownloadFile downloads the file specified by ResourceId. Set ResourceId to the Id of the file to download before calling this method. The file will be downloaded to the stream specified (if any) by SetDownloadStream. If a stream is not specified and LocalFile is set the file will be saved to the specified location. If a stream is not specified and LocalFile is not set the file data will be held by ResourceData.

To decrypt an encrypted file set EncryptionAlgorithm and EncryptionPassword before calling this method.


box.ResourceId = "50619395801"
box.LocalFile = "../MyFile.zip";
box.DownloadFile();

Resuming Downloads

The component also supports resuming failed downloads by using the StartByte property. If the download was interrupted, set StartByte to the appropriate offset before calling this method to resume the download.


box.ResourceId = myId;
box.LocalFile = downloadFile;
box.DownloadFile();

//The transfer is interrupted and DownloadFile() above fails. Later, resume the download:

//Get the size of the partially download file
box.StartByte = new FileInfo(downloadFile).Length; 
box.ResourceId = myId;
box.LocalFile = downloadFile;
box.DownloadFile();

Resuming Encrypted File Downloads

Resuming encrypted file downloads is only supported when LocalFile was set in the initial download attempt. When beginning an encrypted download if LocalFile is set the component will create a temporary file in TempPath to hold the encrypted data until it is complete.

If the download is interrupted DownloadTempFile will be populated with the temporary file holding the partial data. When resuming, DownloadTempFile must be populated along with StartByte to allow the remainder of the encrypted data to be downloaded. Once the encrypted data is downloaded it will be decrypted and written to LocalFile.

box.ResourceId = myId;
box.LocalFile = downloadFile;
box.EncryptionPassword = "password";
box.DownloadFile();

//The transfer is interrupted and DownloadFile() above fails. Later, resume the download:

//Get the size of the partially download temp file
box.StartByte = new FileInfo(box.Config("DownloadTempFile")).Length; 
box.ResourceId = myId;
box.LocalFile = downloadFile;
box.EncryptionPassword = "password";
box.DownloadFile();

Uploading Files

UploadFile uploads a file to the folder specified by ResourceParentId. If ResourceParentId is not specified the file will be uploaded to the root directory. This method returned the Id of the uploaded file. If the file already exists the server will return an error.

The FileName parameter specifies the name of the file. Naming restrictions:

  • Names must be 255 characters or less.
  • Names with non-printable ASCII are not supported.
  • Names with the characters "/", "\", or trailing whitespace are not supported.
  • The special names "." and ".." are not supported.

LocalFile specifies the file to upload. The data to upload may also be set in ResourceData or set by SetUploadStream. To encrypt a file set EncryptionAlgorithm and EncryptionPassword.

The following properties are applicable when calling UploadFile:


box.LocalFile = "../MyFile.zip";
box.UploadFile("MyFile.zip");

After uploading a file the Resource* properties are populated with information about the uploaded file.

Additional Functionality

The Box component offers advanced functionality beyond simple uploads and downloads. For instance:

Property List


The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

AccountThis property defines details about the account.
AuthorizationOAuth 2.0 Authorization Token.
EncryptionAlgorithmThe encryption algorithm.
EncryptionPasswordThe encryption password.
FirewallA set of properties related to firewall access.
LocalFileThe location of the local file.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
MetadataFieldsA collection of metadata fields associated with the resource.
OverwriteWhether to overwrite the local or remote file.
ProxyA set of properties related to proxy access.
QueryParamsAddtional query parameters to be included in the request.
ResourceCountThe number of files and folders.
ResourceCreatedByThe email of the creator of the resource.
ResourceCreatedDateThe date on which the resource was created.
ResourceDataHolds the file data after downloading or sets the file data before uploading or updating.
ResourceDeletedWhether the resource is deleted.
ResourceDeletedDateThe date on which the resource was deleted.
ResourceDescriptionA short description of the file or folder.
ResourceETagThe ETag of the resource.
ResourceHashThe SHA1 hash of the file.
ResourceIdThe unique identifier of the resource.
ResourceIndexSelects the file or folder.
ResourceMarkerA marker when list results are paged.
ResourceModifiedByThe email of the user who last modified the resource.
ResourceModifiedDateThe date on which the resource was modified.
ResourceNameThe name of the resource.
ResourceOwnerThe email of the resource owner.
ResourceParentIdThe Id of the parent resource.
ResourcePurgedDateThe date on which the resource will be permanently deleted.
ResourceRevisionThe revision of the file.
ResourceSizeThe size of the resource in bytes.
ResourceSyncStateThe sync state of the folder.
ResourceTagsA comma separate list of tags.
ResourceTypeIndicates whether the current entry is a folder or a file.
SearchMarkerA marker when searches are paged.
SharedResourceInfoDefines information about the shared resource.
SSLAcceptServerCertInstructs the component to unconditionally accept the server certificate that matches the supplied certificate.
SSLCertThe certificate to be used during SSL negotiation.
SSLServerCertThe server certificate for the last established connection.
StartByteThe byte offset from which to start the upload or download.
ThumbnailFormatThe thumbnail format.
ThumbnailSizeThe size of the thumbnail in pixels.
TimeoutA timeout for the component.
TotalSpaceThe total allowed space in bytes.
UsedSpaceThe amount of space used in bytes.

Method List


The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

AddQueryParamAdds a query parameter to the QueryParams properties.
ConfigSets or retrieves a configuration setting .
CopyResourceCopies the specified resource to a new location.
CreateFolderCreates a folder with the specified name.
CreateMetadataCreates metadata for a file.
DeleteMetadataDeletes all metadata for a file.
DeleteResourceDeletes the specified resource.
DownloadFileDownloads a file.
GetAccountInfoRetrieves information about the current user account.
GetMetadataRetrieves metadata for the file.
GetPreviewLinkGets a link that may be used to preview the resource.
GetResourceInfoRetrieves information about the specified resource.
GetSharedResourceInfoGets information about a shared resource.
GetThumbnailRetrieves a thumbnail image of the current resource.
InterruptInterrupt the current method.
ListDeletedResourcesLists deleted resources.
ListResourcesLists the resources in the specified folder.
ListRevisionsLists revisions for a file.
LockFileLocks the specified file.
PromoteRevisionPromotes a specific revision of a file to the current version.
RestoreResourceRestores a deleted resource.
SearchThis method searches resources for the specified query.
SetDownloadStreamSets the stream to which the downloaded file will be written.
SetUploadStreamSets the stream from which data is read when uploading.
ShareResourceShares the specified file or folder.
UnlockFileUnlocks the specified file.
UnshareResourceStops sharing a resource.
UpdateMetadataUpdates metadata fields for a file.
UpdateResourceUpdates the file or folder.
UploadFileUploads a file.

Event List


The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

EndTransferFired when a document finishes transferring.
ErrorInformation about errors during data delivery.
ResourceListFired for each resource listed.
SSLServerAuthenticationFired after the server presents its certificate to the client.
SSLStatusShows the progress of the secure connection.
StartTransferFired when a document starts transferring (after the headers).
TransferFired while a document transfers (delivers document).

Configuration Settings


The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.

DownloadTempFileThe temporary file used when downloading encrypted data.
IncludeFileHashWhether to include the SHA1 hash when uploading a file.
MaxResultsThe maximum number of results to return when searching or listing resources.
ResourceClientCreatedDateA client assigned creation date.
ResourceClientModifiedDateA client assigned modified date.
RetryAfterThe number of seconds after which to retry the request.
TempPathThe path to the directory where temporary files are created.
EncryptionIVThe initialization vector to be used for encryption/decryption.
EncryptionKeyThe key to use during encryption/decryption.
XPathProvides a way to point to a specific element in the returned XML response.
XElementThe name of the current element.
XParentThe parent of the current element.
XSubTreeA snapshot of the current element in the document.
XTextThe text of the current element.
XChildCountThe number of child elements of the current element.
XChildName[x]The name of the child element.
XChildXText[x]The inner text of the child element.
AcceptEncodingUsed to tell the server which types of content encodings the client supports.
AllowHTTPCompressionThis property enables HTTP compression for receiving data.
AllowIdenticalRedirectURLAllow redirects to the same URL.
AppendWhether to append data to LocalFile.
AuthorizationThe Authorization string to be sent to the server.
BytesTransferredContains the number of bytes transferred in the response data.
EncodeURLIf set to true the URL will be encoded by the component.
FollowRedirectsDetermines what happens when the server issues a redirect.
GetOn302RedirectIf set to true the component will perform a GET on the new location.
HTTPVersionThe version of HTTP used by the component.
IfModifiedSinceA date determining the maximum age of the desired document.
KeepAliveDetermines whether the HTTP connection is closed after completion of the request.
MaxRedirectAttemptsLimits the number of redirects that are followed in a request.
OtherHeadersOther headers as determined by the user (optional).
ProxyAuthorizationThe authorization string to be sent to the proxy server.
ProxyAuthSchemeThe authorization scheme to be used for the proxy.
ProxyPasswordA password if authentication is to be used for the proxy.
ProxyPortPort for the proxy server (default 80).
ProxyServerName or IP address of a proxy server (optional).
ProxyUserA user name if authentication is to be used for the proxy.
TransferredDataLimitThe maximum number of incoming bytes to be stored by the component.
TransferredHeadersThe full set of headers as received from the server.
UseChunkedEncodingEnables or Disables HTTP chunked encoding for transfers.
ChunkSizeSpecifies the chunk size in bytes when using chunked encoding.
UserAgentInformation about the user agent (browser).
KerberosSPNThe Service Principal Name for the Kerberos Domain Controller.
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the component whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe TCP port in the local host where the component binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
RecordLengthThe length of received data records.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
UseIPv6Whether to use IPv6.
TcpNoDelayWhether or not to delay when sending packets.
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
CodePageThe system code page used for Unicode to Multibyte translations.

 
 
Copyright (c) 2017 /n software inc. - All rights reserved.
Build 1.0.6240.0