Downloading to a stream instead of a file?

Is it possible to download from cloud storage to a steam instead of a file?


Currently downloads from cloud storage services are always saved to a file. 
However this is a good suggestion and we'll consider adding this feature in a future version.


As my colleague already mentioned, the google drive items are always saved to a file when performing a download, but you can manually add a code snippet that will help in downloading items to a stream instead. For the purpose of testing if the data is correct, we save the memorystream to a file.

procedure TForm1.Button1Click(Sender: TObject);
  it: TTMSFNCCloudGoogleDriveItem;
  //a random google drive item
  it := TTMSFNCCloudGoogleDriveItem(TMSFNCCloudGoogleDrive1.Drive.Items[4]);

  TMSFNCCloudGoogleDrive1.Request.Host := it.DownloadURL + '&access_token=' + TMSFNCCloudGoogleDrive1.Authentication.AccessToken;
  TMSFNCCloudGoogleDrive1.Request.Method := rmGET;
  TMSFNCCloudGoogleDrive1.Request.DataString := it.FileName;
  TMSFNCCloudGoogleDrive1.Request.ResultType := rrtStream;
  TMSFNCCloudGoogleDrive1.Request.ResultFileSize := it.Size;
  TMSFNCCloudGoogleDrive1.Request.Name := 'DOWNLOAD FILE TO STREAM';

  procedure(const ARequestResult: TTMSFNCCloudBaseRequestResult)
    ms: TMemoryStream;
    ms := ARequestResult.ResultStream;
    ms.SaveToFile('E:\My Google Drive Files\' + ARequestResult.DataString);

Pieter Scheldeman2019-12-04 09:20:48

Thanks Bart and Pieter.

Before adding for all cloud services such code, I think I will wait for any update in the future, containing loading and saving from stream :)

Was downloading to a stream ever implemented ? I've tried the code provided later in this thread and I get an error 403 :
# We're sorry...

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.

It also doesn't seem to work with OneDrive. Is there a working sample that can download a file to stream from Google Drive or OneDrive ?