Is it possible to set FileSlicingCount at runtime..? I want the user to set FileSlicingCount for specific download. And also the ability to set different chunk no for different downloading.
Same feature for DownloadConcurrentLimit. I want the user to set DownloadConcurrentLimit and also able to change DownloadConcurrentLimit at runtime.
@maulik9898 You would have to create a custom downloader and override method fun getFileSlicingCount(request: ServerRequest, contentLength: Long): Int?. Then set the custom downloader on the fetch configuration.
@Override
public void onCreate() {
super.onCreate();
final FetchConfiguration fetchConfiguration = new FetchConfiguration.Builder(this)
.enableRetryOnNetworkGain(true)
.setDownloadConcurrentLimit(3)
.setHttpDownloader(new CustomParallelDownloader())
.build();
Fetch.Impl.setDefaultInstanceConfiguration(fetchConfiguration);
RxFetch.Impl.setDefaultRxInstanceConfiguration(fetchConfiguration);
}
public static class CustomParallelDownloader extends OkHttpDownloader {
public CustomParallelDownloader() {
super(Downloader.FileDownloaderType.PARALLEL);
}
@Nullable
@Override
public Integer getFileSlicingCount(@NotNull Downloader.ServerRequest request, long contentLength) {
//return new count here after checking request and content length
return super.getFileSlicingCount(request, contentLength);
}
}
Note custom FileSlicingCount only works for Parallel Downloaders. Hope this helps.
Ok, so is there any way i can customise this fileslicing option for each and every new download request
@maulik9898 The fileSlicingCount method is called for each download request when started. So you are able to set the slice count for any download request.
Ohh i get it now. Thank you for this awesome library
Most helpful comment
@maulik9898 The
fileSlicingCountmethod is called for each download request when started. So you are able to set the slice count for any download request.