Best way to copy CloudItem data

Hello,

I need help. After a SearchFile I want to save the CloudItem data in a separate variable.

var
  remCloudItem : TCloudItem;
//..
If AdvGDrive.SearchFile(Filename, true) then
   If AdvGDrive.Drive <> NIL then
      for i := 0 to AdvGDrive.Drive.Count-1 do
        remCloudItem := AdvGDrive.Drive.Items;


With the next  AdvGDrive.SearchFile or  AdvGDrive.GetDriveInfo my saved remCloudItem has undefined data.

But with remCloudItem.Assign(AdvGDrive.Drive.Items) the program hangs in an endless loop.

What will be the best way to save the ClouItem data?

Many thanks for your help.




Hi,


I have not been able to reproduce this issue. The sample code you provided is working as expected.
Can you please explain exactly what you mean with undefined data?

Yes, of course the sample works. This isn't the issue.


But if I have to use  AdvGDrive.GetDriveInfo() again, the variable remCloudItem has no more the saved data from before. At these moment there are many kyrillic letters in the different values.

The problem will be that remCloudItem := AdvGDrive.Drive.Items don't copy the data, but set only the pointer. And I'm looking for a way to copy the data e.g. remCloudItem.Assign();
The assign call is working as expected in the following sample code.
If the problem persists, please provide a ready to run sample code so I can further investigate this.

var
  i: integer;
  remCloudItem : TCloudItem;
begin
  remCloudItem := TCloudItem.Create(nil);

  If AdvGDrive1.SearchFile(FileName, true) then
     If AdvGDrive1.Drive <> NIL then
        for i := 0 to AdvGDrive1.Drive.Count-1 do
          remCloudItem.Assign(AdvGDrive1.Drive.Items[i]);

Hello,


a few seconds ago I send to you an sample code.

In the code you sent, myCloudItem is never created, so it is normal that when you try to call Assign() for a nil object, it will cause an AV


procedure TForm5.btnUploadClick(Sender: TObject);
var
  myCloudItem : TCloudItem;
  localFileName: string;
  i: Integer;
begin
  localFileName := 'c:\xyztest.jpg';

  myCloudItem := NIL;

  if myCloudItem = NIL then
  begin
    If AdvGDrive1.SearchFile(ExtractFileName(localFileName), true) then
    begin
      If AdvGDrive1.Drive <> NIL then
        for i := 0 to AdvGDrive1.Drive.Count-1 do
          myCloudItem.Assign(AdvGDrive1.Drive.Items);   // here comes an access violation
    end;
//    AdvGDrive1.GetDriveInfo;
  end;

Oh yeah, you are right. 

I forgot to initiate the clouditem for Assign() because for AdvGDrive.Upate and AdvGDrive.Upload the Clouditem will automatically initiated, right?

The Upload function automatically returns a valid reference to a TCloudItem when there is a succesful upload.