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

Dropbox Control

Properties   Methods   Events   Configuration Settings   Errors  

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

Syntax

Dropbox

Remarks

The Dropbox control provides a simple interface to working with Dropbox. 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 Dropbox. Consult the Dropbox documentation for instructions on this process.

Authentication

Authentication is performed via OAuth 2.0. Use the OAuth control 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 Dropbox 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.

Before calling this method set ResourcePath to the full path to the folder to list. If ResourcePath 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 ResourceType is 1 (rtFolder) only the following properties are applicable:

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.

By default only resources of the specified ResourcePath are returned. To list files included within subfolders set RecurseSubfolders to True.

dropbox.ResourcePath = "/New Folder";
dropbox.ListResources();
for (int i = 0; i < dropbox.ResourceCount; i++)
{
  dropbox.ResourceIndex = i;
  Console.WriteLine(dropbox.ResourceName + ": " + dropbox.ResourceSize);
}

Downloading Files

The DownloadFile method downloads a specific file.

Set ResourcePath to the absolute path of the file to download before calling this method. If LocalFile is set the file will be saved to the specified location. If 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.


dropbox.ResourcePath = "/My Folder/photos.zip"
dropbox.LocalFile = "../MyFile.zip";
dropbox.DownloadFile();

Resuming Downloads

The control 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.


dropbox.ResourcePath = myRemoteFile;
dropbox.LocalFile = downloadFile;
dropbox.DownloadFile();

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

//Get the size of the partially download file
dropbox.StartByte = new FileInfo(downloadFile).Length; 
dropbox.ResourcePath = myRemoteFile;
dropbox.LocalFile = downloadFile;
dropbox.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 control 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.

dropbox.ResourcePath = myRemoteFile;
dropbox.LocalFile = downloadFile;
dropbox.EncryptionPassword = "password";
dropbox.DownloadFile();

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

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

Uploading Files

LocalFile specifies the file to upload. The data to upload may also be set in ResourceData .

The FileName parameter of UploadFile specifies the name of the file to be written.

A file can be uploaded to a specific folder by specifying the absolute path in the FileName parameter, or by setting ResourcePath to the folder. Absolute paths begin with a "/" character and must include the full path beginning at the root. For instance:

//Upload to the root folder
  dropbox.ResourcePath = ""; 
  string path = dropbox.UploadFile("test.txt");
  //path is "/test.txt"

//Upload to a folder (relative path)
  dropbox.CreateFolder("/uploadtest");
  path = dropbox.UploadFile("test.txt");
  //path is "/uploadtest/test.txt"

//Upload to a folder (absolute path)
  path = dropbox.UploadFile("/uploadtest/test.txt");
  //path is "/uploadtest/test.txt"

To encrypt a file before uploading set EncryptionAlgorithm and EncryptionPassword.

When the upload is complete the control will fire the UploadComplete event and UploadFile returns the absolute path to the uploaded file.

Upload Notes

Dropbox offers two ways to upload a file. For smaller files a simple upload option is provided to upload data in one request. This is the default option. For larger files uploads can be fragmented into multiple pieces, allowing resuming of uploads that may be interrupted.

Simple

By default the control uses the simple upload mechanism.


dropbox.LocalFile = "../MyFile.zip";
dropbox.UploadFile("/folder/MyFile.zip");

The following properties are applicable when calling UploadFile and UseResumableUpload if False (default - simple upload):

Resumable

To enable resumable uploads set UseResumableUpload to True. This is recommended for large files. The control will automatically fragment the specified file into smaller pieces and upload each individually. FragmentSize may be set to specify the size of the fragment if desired. The default fragment size is 10 MB.

When UseResumableUpload is set to True and UploadFile is called a resumable upload session is started by the control. UploadSessionId is populated with the Id of the session. This value may be needed for additional operations if the upload does not complete normally. Additionally StartByte is updated as necessary by the control to indicate the current offset in the file.

If the upload is interrupted for any reason the upload may be resumed. To resume an upload verify that UploadSessionId and StartByte are populated. If the same instance of the control is used these should already be populated and no special action is needed. Call UploadFile again to resume the upload at the specified StartByte offset.

The FragmentComplete event fires after each fragment is uploaded to indicate overall progress.


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

//The transfer is interrupted and UploadFile() above fails. Later, resume the download.
//Using the same instance StartByte and UploadSessionId are already populated 
//from the previous upload attempt
dropbox.UploadFile("MyFile.zip");

The following properties are applicable when calling UploadFile and UseResumableUpload if True:

Additional Functionality

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

Property List


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

AccountCountryThis property holds the account owner's two-letter country code (if available).
AccountDisplayNameThe display name of the user's Dropbox account.
AccountEmailThe user's e-mail address.
AccountFirstNameThe user's first name.
AccountIdThe unique account Id.
AccountLastNameThe user's last name.
AccountTeamIdThis property is only populated if the user is a member of the team.
AccountTeamNameThis property is only populated if the user is a member of the team.
AccountTypeThe account type.
AuthorizationOAuth 2.0 Authorization Token.
ChangeMarkerA marker identifying the last change in a folder.
EncryptionAlgorithmThe encryption algorithm.
EncryptionPasswordThe encryption password.
FirewallAutoDetectThis property tells the component whether or not to automatically detect and use firewall system settings, if available.
FirewallTypeThis property determines the type of firewall to connect through.
FirewallHostThis property contains the name or IP address of firewall (optional).
FirewallPasswordThis property contains a password if authentication is to be used when connecting through the firewall.
FirewallPortThis property contains the TCP port for the firewall Host .
FirewallUserThis property contains a user name if authentication is to be used connecting through a firewall.
LocalFileThe location of the local file.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
OverwriteWhether to overwrite the local or remote file.
ProxyAuthSchemeThis property is used to tell the component which type of authorization to perform when connecting to the proxy.
ProxyAutoDetectThis property tells the component whether or not to automatically detect and use proxy system settings, if available.
ProxyPasswordThis property contains a password if authentication is to be used for the proxy.
ProxyPortThis property contains the TCP port for the proxy Server (default 80).
ProxyServerIf a proxy Server is given, then the HTTP request is sent to the proxy instead of the server otherwise specified.
ProxySSLThis property determines when to use SSL for the connection to the proxy.
ProxyUserThis property contains a user name, if authentication is to be used for the proxy.
ResourceCountThe number of files and folders.
ResourceDataHolds the file data after downloading or sets the file data before uploading or updating.
ResourceIdA unique identifier for the resource.
ResourceIndexSelects the file or folder.
ResourceMarkerA marker when list results are paged.
ResourceModifiedDateThe last time the resource was modified on Dropbox.
ResourceNameThe name of the resource.
ResourcePathThe path of the current resource.
ResourceRevisionThe current revision of the file.
ResourceSizeThe size of the resource in bytes.
ResourceTypeIndicates whether the current entry is a folder or a file.
SearchMarkerA marker when searches are paged.
SearchModeThe level at which to search.
SharedResourceCountThe number of records in the SharedResource arrays.
SharedResourceExpiresA timestamp indicating when the link to the shared resource expires.
SharedResourceLinkThe link to the shared resource.
SharedResourcePathThe absolute path to the shared resource.
SharedResourceVisibilityThe visibility of the shared resource.
SSLAcceptServerCertEncodedThe certificate (PEM/base64 encoded).
SSLCertEncodedThe certificate (PEM/base64 encoded).
SSLCertStoreThe name of the certificate store for the client certificate.
SSLCertStorePasswordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
SSLCertStoreTypeThe type of certificate store for this certificate.
SSLCertSubjectThe subject of the certificate used for client authentication.
SSLServerCertEncodedThe certificate (PEM/base64 encoded).
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.
UploadSessionIdThe Id of the resumable upload session.
UsedSpaceThe amount of space used in bytes.
UseResumableUploadWhether to use resumable uploads.

Method List


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

ConfigSets or retrieves a configuration setting .
CopyResourceCopies the file or folder specified by ResourcePath to a new location.
CreateFolderCreates the folder at the specified path.
DeleteResourceDeletes the specified resource.
DownloadFileDownloads the specified file.
GetAccountInfoGets information about the account.
GetPreviewThis method download a preview of a resource.
GetResourceInfoGets information about the specified resource.
GetThumbnailGets a thumbnail image.
GetUsageInfoGets the total space allowed and used.
InterruptInterrupt the current method.
ListChangesList recent changes to a folder.
ListResourcesLists the resources in the current folder.
ListRevisionsLists file revisions.
ListSharedResourcesThis method lists information about the shared resources.
MoveResourceMoves the file or folder specified by ResourcePath to a new location.
RestoreResourceRestores a file to a previous revision.
SearchSearches for files and folders matching the query.
ShareResourceShares a resource.
UnshareResourceThis method un-shares the resource.
UploadFileUploads a file.
WaitForChangesThis method waits for changes to a folder for a specified period of time.

Event List


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

EndTransferFired when a document finishes transferring.
ErrorInformation about errors during data delivery.
FragmentCompleteThis event fires after each fragment of a resumable upload is completed.
ResourceListFired for each resource listed.
SearchResultFired for each search result.
SharedResourceListThis event fires when ListSharedResources is called.
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).
UploadCompleteFires after an upload completes.

Configuration Settings


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

DownloadTempFileThe temporary file used when downloading encrypted data.
FragmentSizeThe fragment size.
MaxResultsThe maximum number of search results per page.
PermanentlyDeleteWhether to permanently delete a resource.
RecurseSubfoldersWhether to recurse subfolders when listing resources.
RenameIfExistsWhether to rename the uploaded file if it exists.
ResourceClientDateThe client modified date.
ShortURLWhether to use a shortened URL for the shared resource.
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