Change download logic

Hello,

Currently when i click download file your control automatically download it to user/Download folder and show me a popup to open it. It is possible to change this logic and Stop file to me downloaded in  user/Download folder but still to have this popup in top right to open the file and folder? The idea is that the file will be in the cloud and I want to download it in selected folder. What happen currently is that file is downloaded from the cloud to selected folder and File Manager copy it to user/Download. That is not need.

I use this documentation: https://blazor.syncfusion.com/documentation/file-manager/data-binding#file-download-1

I can easy replace this logic to download file from the cloud to selected folder. but how to open download result popup that is in top right position in the image?

public void BeforeDownload(BeforeDownloadEventArgs<FileManagerDirectoryContent> args)
    {
        var downloadData = FileManagerService.Download(args.DownloadData.Path, args.DownloadData.Names, args.DownloadData.DownloadFileDetails.ToArray());
        args.FileStream = downloadData.FileStream;
        args.DownloadFileName = downloadData.FileDownloadName;
    }

Attachment: Screenshot_6_8628c50e.jpg

11 Replies

PM Prasanth Madhaiyan Syncfusion Team April 23, 2025 07:18 AM UTC

Hi Dimitar,

Greetings from Syncfusion support.

We were a bit unclear about your exact requirement regarding the Blazor FileManager component with flat data sample. From your update, it seems that you want to avoid downloading the file to the default Downloads folder, and instead, download it directly to a selected folder while still showing the top-right popup notification (as seen in the image).

To help us better understand your use case and provide you with a prompt and accurate solution, could you please share the following:

  • A detailed explanation of your requirement.

  • A pictorial representation (screenshot or illustration) showing the desired behavior.

  • Information about how you're currently selecting the custom folder for downloads.

Once we receive this information, we’ll be able to further analyze and assist you accordingly. Kindly get back to us with the requested details.

Regards,

Prasanth Madhaiyan.



DI Dimitar April 23, 2025 07:30 AM UTC

Hello,

Actually you unerstand my requirement. But lets give you more clear picture.

From uploaded image: red box is file structure on HDD. Selected folder is Documents (  D:/Downloads/Documents ). Files do not exist on HDD. They are in the cloud. When I click Download button my logic download the file from cloud in D:/Downloads/Documents on my HDD. Then your logic continue to download/copy from  D:/Downloads/Documents to

C:\Users\xxx\Downloads\ I can stop this of course but want to have download finish popup in blue rectangle in uploaded picture.


what I need is:

public void BeforeDownload(BeforeDownloadEventArgs<FileManagerDirectoryContent> args)

    {

        //my download logic from cloud to SelectedFolder: currently is D:/Downloads/Documents

        //open download result popup without to copy file from D:/Downloads/Documents to  C:\Users\xxx\Downloads\

    }


Attachment: Screenshot_7_27559214.jpg


PM Prasanth Madhaiyan Syncfusion Team April 24, 2025 09:13 AM UTC

Hi Dimitar,

Based on the details you have shared, we understand that you want to customize the dialog popup highlighted in the red box in the attached screenshot. However, we would like to inform you that this is the default browser download dialog, and it is not related to the FileManager component’s dialog popup. Since this dialog is controlled by the browser itself, it is not possible to customize it from our end.

Screenshot: 


Kindly review the provided information, and let us know if you need any further assistance.

Regards,

Prasanth Madhaiyan.



DI Dimitar April 24, 2025 09:15 AM UTC

That is good. How to trigger this box to show? You trigger it by somehow in your code.



PM Prasanth Madhaiyan Syncfusion Team April 25, 2025 07:45 AM UTC

Hi Dimitar,

The file download popup in the browser is ultimately triggered by the client-side Blazor FileManager component, but it uses the server-side method in your FileManagerService to get the file stream and filename. 

Client-side codes:

[Home.Razor]

...

@using Syncfusion.Blazor.FileManager

@using BlazorApp1
@inject Microsoft.AspNetCore.Components.NavigationManager UriHelper
@inject FileManagerService FileManagerService
<div class="control-section">
    @* Initialization of default File Manager component *@
    <SfFileManager TValue="FileManagerDirectoryContent" AllowDragAndDrop="true" ShowThumbnail="false" ShowFileExtension="false">
        <FileManagerEvents TValue="FileManagerDirectoryContent" OnRead="OnReadAsync" ItemsDeleting="ItemsDeletingAsync" FolderCreating="FolderCreatingAsync" Searching="SearchingAsync" ItemRenaming="ItemRenamingAsync" ItemsMoving="ItemsMovingAsync" BeforeImageLoad="BeforeImageLoadAsync" BeforeDownload="BeforeDownload"></FileManagerEvents>
    </SfFileManager>
</div>
@code {

    ...
    public void BeforeDownload(BeforeDownloadEventArgs<FileManagerDirectoryContent> args)
    {
        var downloadData = FileManagerService.Download(args.DownloadData.Path, args.DownloadData.Names, args.DownloadData.DownloadFileDetails.ToArray());
        args.FileStream = downloadData.FileStream;
        args.DownloadFileName = downloadData.FileDownloadName;
    }
}

Here, we supply the file stream and file name from the FileManagerService.Download(...) response to args.FileStream and args.DownloadFileName.

This allows the Syncfusion FileManager to initiate the browser's download behavior using the provided stream and file name.

Check out the shared details and let us know if you need any further assistance. 

Regards,

Prasanth Madhaiyan.



DI Dimitar April 25, 2025 11:01 AM UTC

And the browser download the file automatically in Download folder?



PM Prasanth Madhaiyan Syncfusion Team April 28, 2025 12:37 PM UTC

Hi Dimitar,

Yes, browsers typically download files to the "Downloads" folder by default. However, you can change this default location in your browser settings.

Default Location:

Most browsers, like Chrome, Firefox, and Edge, automatically save downloaded files to the "Downloads" folder on your computer. 

Changing the Default:

You can usually find settings to change the default download location in your browser's settings panel. For example, in Chrome, you can adjust the download settings under Privacy and security > Site Settings > Additional permissions > Automatic downloads. 


Check out the shared details and let us know if you need any further assistance.

Regards,

Prasanth Madhaiyan.



DI Dimitar April 28, 2025 02:37 PM UTC

I not need this. I will make control that will match download result box design.



PM Prasanth Madhaiyan Syncfusion Team April 29, 2025 07:36 AM UTC

Hi Dimitar,

Based on the details you have shared, the browser’s download dialog popup is not controlled by the Syncfusion Blazor FileManager component.
This dialog behavior is entirely dependent on the browser being used, and it may vary across different browsers. As a result, we are unable to customize or modify the appearance or behavior of the browser’s download dialog from our end.

Regards,

Prasanth Madhaiyan.



DI Dimitar April 29, 2025 08:10 AM UTC

Hello,

Yes, don't worry about this.

Thank you



FL Florence Lilian Awino Syncfusion Team April 30, 2025 08:16 AM UTC

Hi Dimitar,

If you need any assistance related to our components, please let us know.

Regards,

Florence L.



Loader.
Up arrow icon