public async Task <IHttpTransfer> Create(HttpTransferRequest request) { var native = new Native.Request(request.LocalFilePath.ToNativeUri()); //native.SetAllowedNetworkTypes(DownloadNetwork.Wifi) //native.SetAllowedOverRoaming() //native.SetNotificationVisibility(DownloadVisibility.Visible); //native.SetRequiresDeviceIdle //native.SetRequiresCharging //native.SetTitle("") //native.SetVisibleInDownloadsUi(true); native.SetAllowedOverMetered(request.UseMeteredConnection); foreach (var header in request.Headers) { native.AddRequestHeader(header.Key, header.Value); } var id = this.GetManager().Enqueue(native); //await this.repository.Set(id.ToString(), new HttpTransferStore //{ //}); return(null); }
protected override async Task <HttpTransfer> CreateDownload(HttpTransferRequest request) { if (request.HttpMethod != HttpMethod.Get) { throw new ArgumentException("Only GETs are supported for downloads on Android"); } var access = await this.Services.Android.RequestAccess(Manifest.Permission.WriteExternalStorage); if (access != AccessState.Available) { throw new ArgumentException("Invalid access to external storage - " + access); } access = await this.Services.Android.RequestAccess(Manifest.Permission.ReadExternalStorage); if (access != AccessState.Available) { throw new ArgumentException("Invalid access to external storage - " + access); } var dlPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath; var path = Path.Combine(dlPath, request.LocalFile.Name); var native = new Native .Request(Android.Net.Uri.Parse(request.Uri)) .SetDescription(request.LocalFile.FullName) .SetDestinationUri(ToNativeUri(path)) // WRITE_EXTERNAL_STORAGE .SetAllowedOverMetered(request.UseMeteredConnection); foreach (var header in request.Headers) { native.AddRequestHeader(header.Key, header.Value); } var id = this.Services.Android.GetManager().Enqueue(native); return(new HttpTransfer( id.ToString(), request.Uri, request.LocalFile.FullName, false, request.UseMeteredConnection, null, 0, 0, HttpTransferState.Pending )); }