Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not using fragmented downloads will also generate two download requests. #172

Open
fusheng357 opened this issue Nov 15, 2024 · 3 comments
Open
Assignees
Labels
question Further information is requested

Comments

@fusheng357
Copy link

My download path needs to limit the number of downloads, but if I don't use split downloads, it will still generate two download requests. I read the official documentation and it may be because the file size is requested from the download server once before downloading. Is there any way to generate only one download request or not request the file size?

@bezzad bezzad self-assigned this Nov 16, 2024
@bezzad bezzad added the question Further information is requested label Nov 16, 2024
@bezzad
Copy link
Owner

bezzad commented Nov 16, 2024

Before initiating the download, it's necessary to determine the file size in order to allocate space for it on the local storage and configure the chunk sizes appropriately. This typically results in an initial request to the server to fetch the file size before the actual download process begins.

If your requirement is to limit the number of requests to a single one, you could consider using the HttpClient class directly. However, please note that the Downloader is designed specifically to manage various events and issues that may occur during the download process. For instance, if your connection is interrupted, the Downloader is built to automatically reconnect and resume the download. This functionality requires multiple requests and retry logic, which might conflict with any limitations you’re trying to enforce on the number of requests.

Could you provide more details on why you need to limit the number of requests? With more context, we may be able to suggest a better solution that meets your needs.

@fusheng357
Copy link
Author

Because I want to limit the number of times a file can be downloaded, each file is limited to five times.

@bezzad
Copy link
Owner

bezzad commented Nov 17, 2024

@fusheng357 I think your solution is not safe because a download can be reconnect because of many reasons. You can manage this with the Downloader events like:

// Provide `FileName` and `TotalBytesToReceive` at the start of each download
downloader.DownloadStarted += OnDownloadStarted;

// Provide any information about chunker downloads, 
// like progress percentage per chunk, speed, 
// total received bytes and received bytes array to live streaming.
downloader.ChunkDownloadProgressChanged += OnChunkDownloadProgressChanged;

// Provide any information about download progress, 
// like progress percentage of sum of chunks, total speed, 
// average speed, total received bytes and received bytes array 
// to live streaming.
downloader.DownloadProgressChanged += OnDownloadProgressChanged;

// Download completed event that can include errors or 
// canceled or download completed successfully.
downloader.DownloadFileCompleted += OnDownloadFileCompleted;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Status: No status
Development

No branches or pull requests

2 participants