ParentFolder always nil with GetFolderListxxx functions

Hello

I am currently migrating (with difficulty) my Android application that was written with legacy TMSFMXCloudPack components to the new TMSFNCCloudPack components.

I see that file storage is similar except that when I use the GetFolderListHierarchical or GetFolderList function, the ParentFolder properties of the items are always nil even though I am indeed in a subfolder.

As a result, I cannot upload to the correct target directory (so, files are uploaded in the root drive)

I am using TMSFNCCloudStorageServices because my app can connect to Dropbox, OneDrive, and Drive.

Why is ParentFolder always nil?

Sample code (added on an button2 in CloudStorageDemo) :

My file in drop box : \Demo\Test.cbf


function TForm1.RechercheCloudItem(ci: TTMSFNCCloudItems; sNom: String; cit: TTMSFNCCloudItemType): Integer;
var
  bTrouve: Boolean;
  i: Integer;
begin
  bTrouve := False;
  i := 0;
  while (i < ci.Count) and (not bTrouve) do
  begin
    bTrouve := (LowerCase(ci.Items[i].FileName) = LowerCase(sNom)) and (ci.Items[i].ItemType = cit);
    Inc(i);
  end;

  if (bTrouve) then
    Result := Pred(i)
  else
    Result := -1;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  cis: TTMSFNCCloudItems;
  ci: TTMSFNCCloudItem;
  i: Integer;
begin
  TMSFNCCloudStorageServices1.BeginSync;
  try
    cis := TMSFNCCloudStorageServices1.GetFolderListHierarchical(nil);

    i := RechercheCloudItem(cis, 'Demo', ciFolder);
    if (i >= 0) then
    begin
      cis := TMSFNCCloudStorageServices1.GetFolderListHierarchical(cis.Items[i]);

      i := RechercheCloudItem(cis.Items[i].Folder, 'Test.cbf', ciFile);
      if (i >= 0) then
        ci := cis.Items[i];
    end;
  finally
    TMSFNCCloudStorageServices1.EndSync;
  end;
end;

At the end, ci points on Test12.cbf but ParentFolder is nil

Hello,

Your sample code does not clearly show the process of uploading files. Could you please refer to the CloudStorageServices Demo application? It provides a clear demonstration of how to upload files within the same folder that is retrieved using GetFolderListHierarchical.

Hi

The example code is simply trying to show that when traversing subdirectories, the ParentFolder remains nil.

I've given up on using the ParentFolder value with the items returned by GetFolderListHierarchical. I've managed with the GetFolderList function and store the paths of the directories explored by the user myself.

I still think there's a problem with this ParentFolder value always being nil.

Hi

It's strange to clear FHierarchicalFolder.Folder on each GetFolderListHierarchical call.


function TTMSFNCCustomCloudDropBox.GetFolderListHierarchical(AFolder: TTMSFNCCloudItem; AIsRootFolder: Boolean = False; ADataObject: TObject = nil): TTMSFNCCloudItems;
begin
  //Clear contents of previous GetFolderListHierarchical calls
  if Assigned(FHierarchicalFolder) and Assigned(FHierarchicalFolder.Folder) then
    FHierarchicalFolder.Folder.Clear;

  Result := GetFolderListInt(AFolder, True, AIsRootFolder);
end;

If we call the function on a folder and then the same function on a subfolder resulting from the first call, we no longer have the information from the first call...

The GetFolderListHierarchical will get the list of file in a specified folder. (If the folder is not specified the contents of the root folder are returned.) The result only contains the contents of the specified folder, not the entire folder structure.
The folder structure is maintained in the Drive collection property.