Simple File Upload to BOX without TreeView in VCL Cloud Pack

How do I do a simple upload of file Test.bmp to BOX directory: '\TestDirOnBox' without a TreeView ?

Upload(Nil, 'Test.bmp') ---> Uploads file to Root OK
Upload('\TestDirOnBox', 'Test.bmp'); ---> Does Nothing

I am using the latest version of VCL Cloud Pack and Delphi Berlin.

Thanks in Advance...

John

Is TestDirOnBox and existing folder on the Dropbox root?

Hey Bruno,

Yes, \TestDirOnBox\ is an existing folder on BOX.

  1. Should it be written as TestDirOnBox?
  2. Do you get an error message? Result code?
  3. Can you enable logging and inspect the log file for details?

No error messages at all. The 1st parameter is a TCloudItem not a string. How is the resulting folder selected. I think a TCloudItem is required:

function TAdvCustomBoxNetDrive.Upload(Folder: TCloudItem; const FileName: string)

Upload has an overload, one with TCloudItem, one with string.
To find the TCloudItem for the folder use GetFolderInfo().
If a problem persists, inspect the log file for details.

A slight modification to your UCloudStorageDemo exposes the problem.

Change
nci := Storage.Upload(ci, fn);
to:
nci := Storage.Upload('\ARootFolderOnBoxCloud', fn);
in the Upload function

Log onto the Box Cloud and press "Upload"
nci is not valid and the function returns nothing.
I think other Cloud Servers have the same problem.

I have tried everything and believe there is a problem with your, otherwise excellent, Cloud library.

Cheers,

John

Hey Bruno,

Only DropBox returns a TDropBoxItem:

function GetFolderInfo(const FolderName: string): TDropBoxItem; overload;

All the other GetFolderInfo functions do not return a TDropBoxitem:

function GetFolderInfo(const FolderName: string; Items: TDropBoxItems): boolean; overload;

Is there some way to create and populate a TDropBoxitem manually ?

Regards,

Jonn

TDropBoxItem descends from TCloudItem.
With TAdvDropBox , GetFolderInfo() returns a TDropBoxItem and you can use this result (or cast to) a TCloudItem.

Hey Bruno,

I have:

StorageListArray : Array of Object;

StorageListArray[i] := TAdvBoxNetDrive.Create(nil)

Casting a TAdvBoxNetDrive as TAdvDropBox produces an "Access Violation" error in the following function call:

UPLOAD(TAdvDropBox(StorageListArray[i]).GetFolderInfo('\PPPPPPPPPP'), PhotoFileName);

Note: Replacing TAdvDropBox(StorageListArray[i]).GetFolderInfo('\PPPPPPPPPP') with nil above correctly uploads file to root on Box:
UPLOAD(nil, PhotoFileName);

I'm sorry but I don't understand how what you do related to what I instructed and how you think to mix TAdvBoxNetDrive with TAdvDropBox.

Use something like:

var
  di: TDropBoxItem;

di := AdvDropBox1.GetFolderInfo(FolderNameInRoot);
if Assigned(di) then
AdvDropBox.Upload(di, FileName);

I am trying to use all Cloud providers in my App. Your example only works for DropBox. I have been testing BoxNet. My question is how to use all Cloud providers to "Upload" to BoxNet for example.

Bruno Fierens TMS Support
July 23

I'm sorry but I don't understand how what you do related to what I instructed and how you think to mix TAdvBoxNetDrive with TAdvDropBox.

Use something like:

var
  di: TDropBoxItem;

di := AdvDropBox1.GetFolderInfo(FolderNameInRoot);
if Assigned(di) then
AdvDropBox.Upload(di, FileName);

Please see our demo under \Demo\CloudStorageDemo , this uses all cloud storage providers in an agnostic way in a single app.

For example trying to connect to BoxNet:

AdvBoxNet1 := TAdvBoxNetDrive.Create(nil);
AdvBoxNet1.App.Secret := 'yyy';
AdvBoxNet1.Key := 'xxx';

di := AdvBoxNet1.GetFolderInfo('/9999999999');

get error on AdvBoxNet GetFolderInfo which returns no value and requires a second parameter: TBoxNetItems:

I am trying to use all Cloud providers in my App. Your example only works for DropBox. I have been testing BoxNet. My question is how to use all Cloud providers to "Upload" to BoxNet for example.

Bruno Fierens TMS Support
July 23

I'm sorry but I don't understand how what you do related to what I instructed and how you think to mix TAdvBoxNetDrive with TAdvDropBox.

Use something like:

var
  di: TDropBoxItem;

di := AdvDropBox1.GetFolderInfo(FolderNameInRoot);
if Assigned(di) then
AdvDropBox.Upload(di, FileName);

There are 8 cloud storage services in our demo.
If it doesn't work for one specific service, please enable logging on the component and inspect the log file to see if there are any obvious error messages there.