Search code examples
genexus

How to use StorageProvider.Download(...) to download private files?


When using "StorageProvider.Download(...)", it seems that I can only download files uploaded to the public storage.

Is there a way to download private uploaded files to my server local storage?

I´m using Azure external storage provider.

Thanks!

Example:

// In this case the file is downloaded to the local filesystem:
&LocalFile.Source = 'LocalFile.txt'
&Result = &StorageProvider.Download('AzurePublicFile.txt', &LocalFile, &Messages)

// In this case the file is not downloaded locally, it only loads a reference to the URI in the Azure blob container:
&LocalFile.Source = 'LocalFile.txt'
&Result = &StorageProvider.GetPrivate('AzurePrivateFile.txt', &LocalFile, 5, &Messages)

Solution

  • Try something like this:

    StorageProvider.GetPrivate(...., &File)
    &URL = &File.GetURI()
    &HttpClient.Execute('GET', &URL)
    &HttpClient.ToFile("C:\....")
    

    Update: StorageProvider.DownloadPrivate() will be available in GeneXus 16 Upgrade 2.