Problem with OneDrive and Version 2.x

Hi,

since version 2.0 I get the following error, if I call TTMSFNCCloudMicrosoftOneDrive.GetFolderListHierarchical(nil) to get the files starting from Root.

"nil can not be assigned to TTMSFNCCloudMicrosoftOneDriveItems"

In 1.4.x it worked. What was changed?

Heiko Schröder

Thank you for notifying us.
This issue has been resolved and the update will be available with the next TMS FNC Cloud Pack release.

As a workaround you can use GetFolderList instead to get the content of the root folder.

TMSFNCCloudMicrosoftOneDrive1.GetFolderList(nil);

Thanks for the incremental source, TTMSFNCCloudMicrosoftOneDrive.GetFolderListHierarchical(nil) works again.

But I have a new issue in my code, which works with (FNC Cloud 1.4).
I iterate the folders to get my special folder and in event FNCOneDriveGetFolderList() I save the folder information as follow:

FolderParts is an array which indicates the folder level and the foldernames.

for var a := 0 to AFolderList.Count-1 do
begin
  if (AFolderList.Items[a].ItemType = ciFolder)
  and (AFolderList.Items[a].FileName = FolderParts[MainDlg.iLevel_SearchFolder]) then
  begin
      MainDlg.CI_AppFolderOneDrive := AFolderList.Items[a];
// ...
  end;
end;

After completetion the GetFolderList() event, now the variable MainDlg.CI_AppFolderOneDrive has not the folder information, it has the information of the last found file, because there are also ItemTypes from ciFiles. After an upload the files will be saved in the root folder of OneDrive.

So I changed my code to:

for var a := 0 to AFolderList.Count-1 do
begin
  if (AFolderList.Items[a].ItemType = ciFolder)
  and (AFolderList.Items[a].FileName = FolderParts[MainDlg.iLevel_SearchFolder]) then
  begin
       if Main1PWDlg.CI_AppFolderOneDrive = NIL then
          Main1PWDlg.CI_AppFolderOneDrive := TTMSFNCCloudItem.Create(NIL);
       Main1PWDlg.CI_AppFolderOneDrive.Assign( AFolderList.Items[a] );
// ...
  end;
end;

In upload situation Main1PWDlg.CI_AppFolderOneDrive has the right folder information, but no Files will be uploaded. In your TTMSFNCCustomCloudMicrosoftOneDrive.Upload() function the variable DFolder.ID is empty, that's why UploadInt() doesn't work.

My question is: how do I have to copy the value of AFolderList.Items[a]; to my MainDlg.CI_AppFolderOneDrive? Or is there another issue in your OneDrive component?

Can you please try using a TTMSFNCCloudMicrosoftOneDriveItem object instead of a TTMSFNCCloudItem object? This change should make sure the folder ID is accessible.

Thanks, it seems to work...

if MainDlg.CI_AppFolderOneDrive = NIL then
   MainDlg.CI_AppFolderOneDrive := TTMSFNCCloudMicrosoftOneDriveItem.Create(NIL);
MainDlg.CI_AppFolderOneDrive.Assign( AFolderList.Items[a] as TTMSFNCCloudMicrosoftOneDriveItem );

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.