public async void GetFileAsLocalCachedPath(string dropboxPath, Progress<TransferProgressReport> progressCallback, Action<string> successCallback, Action<Exception> errorCallback, bool useCachedFirst = false, bool useCachedIfOffline = true, bool receiveUpdates = false, CancellationToken? cancellationToken = null)
Asynchronously retrieves file from Dropbox and returns path to local filesystem cached copy.
Parameter | Description |
---|---|
dropboxPath | Path to file on Dropbox |
progressCallback | Progress callback with download percentage and speed |
successCallback | Callback for receiving downloaded file path |
errorCallback | Callback that is triggered if any exception happened |
useCachedFirst | Serve cached version (if it exists) before event checking Dropbox for newer version? |
useCachedIfOffline | Use cached version if no Internet connection? |
receiveUpdates | If true , then when there are remote updates on Dropbox, callback function successCallback will be triggered again with updated version of the file. |
cancellationToken | Cancellation token that can be used to cancel download |
_cancellationTokenSource = new CancellationTokenSource();
DropboxSync.Main.GetFileAsLocalCachedPath(inputField.text,
new Progress<TransferProgressReport>((report) => {
statusText.text = $"Downloading: {report.progress}% {report.bytesPerSecondFormatted}";
}),
(localPath) => {
// success
print($"Completed");
statusText.text = $"<color=green>Local path: {localPath}</color>";
}, (ex) => {
// exception
if(ex is OperationCanceledException){
Debug.Log("Download cancelled");
statusText.text = $"<color=orange>Download canceled.</color>";
}else{
Debug.LogException(ex);
statusText.text = $"<color=red>Download failed.</color>";
}
},
cancellationToken: _cancellationTokenSource.Token);
_cancellationTokenSource = new CancellationTokenSource();
try {
var localPath = await DropboxSync.Main.GetFileAsLocalCachedPathAsync(inputField.text,
new Progress<TransferProgressReport>((report) => {
print($"Downloading: {report.progress}% {report.bytesPerSecondFormatted}");
}), _cancellationTokenSource.Token);
print($"Completed");
}catch(Exception ex){
if(ex is OperationCanceledException){
print("Download cancelled");
}else{
Debug.LogException(ex);
}
}
public void GetFileAsBytes(string dropboxPath, Progress<TransferProgressReport> progressCallback, Action<byte[]> successCallback, Action<Exception> errorCallback, bool useCachedFirst = false, bool useCachedIfOffline = true, bool receiveUpdates = false, CancellationToken? cancellationToken = null)
Asynchronously retrieves file from Dropbox and returns it as byte array
Parameter | Description |
---|---|
dropboxPath | Path to file on Dropbox |
progressCallback | Progress callback with download percentage and speed |
successCallback | Callback for receiving downloaded file bytes |
errorCallback | Callback that is triggered if any exception happened |
useCachedFirst | Serve cached version (if it exists) before event checking Dropbox for newer version? |
useCachedIfOffline | Use cached version if no Internet connection? |
receiveUpdates | If true , then when there are remote updates on Dropbox, callback function successCallback will be triggered again with updated version of the file. |
cancellationToken | Cancellation token that can be used to cancel download |
public void GetFile<T>(string dropboxPath, Progress<TransferProgressReport> progressCallback, Action<T> successCallback, Action<Exception> errorCallback, bool useCachedFirst = false, bool useCachedIfOffline = true, bool receiveUpdates = false, CancellationToken? cancellationToken = null)
Retrieves file from Dropbox and returns it as T (T can be string, Texture2D or any type that can be deserialized from text using JsonUtility)
Parameter | Description |
---|---|
dropboxPath | Path to file on Dropbox |
progressCallback | Progress callback with download percentage and speed |
successCallback | Callback for receiving downloaded object T (T can be string, Texture2D or any type that can be deserialized from text using JsonUtility) |
errorCallback | Callback that is triggered if any exception happened |
useCachedFirst | Serve cached version (if it exists) before event checking Dropbox for newer version? |
useCachedIfOffline | Use cached version if no Internet connection? |
receiveUpdates | If true , then when there are remote updates on Dropbox, callback function successCallback will be triggered again with updated version of the file. |
cancellationToken | Cancellation token that can be used to cancel download |