Skip to content

Commit 18e4624

Browse files
committed
Added file delete option
1 parent a2ff904 commit 18e4624

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

XamarinFileUploader.Droid/XamarinFileUploader.Droid.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
1717
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
1818
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
19-
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
19+
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
2020
<NuGetPackageImportStamp>
2121
</NuGetPackageImportStamp>
2222
</PropertyGroup>

XamarinFileUploader/FileUploaderService.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Newtonsoft.Json;
22
using System;
33
using System.Collections.Generic;
4+
using System.IO;
45
using System.Linq;
56
using System.Net.Http;
67
using System.Text;
@@ -76,6 +77,35 @@ public void CancelUpload(string key) {
7677
OnCancel(r);
7778
}
7879

80+
public void DeleteRequest(string tag)
81+
{
82+
var req = this.Storage.Get().FirstOrDefault(x => x.Identifier == tag);
83+
if (req == null) {
84+
return;
85+
}
86+
try
87+
{
88+
if (!string.IsNullOrWhiteSpace(req.ResponseFilePath) && File.Exists(req.ResponseFilePath))
89+
{
90+
File.Delete(req.ResponseFilePath);
91+
}
92+
} catch
93+
{
94+
95+
}
96+
97+
try
98+
{
99+
if (File.Exists(req.FilePath))
100+
{
101+
File.Delete(req.FilePath);
102+
}
103+
} catch { }
104+
105+
this.Storage.Remove(req);
106+
this.Storage.Save();
107+
}
108+
79109
public async Task StartUpload(string tag, string url, string method, HttpContent content) {
80110

81111
FileUploadRequest request = new FileUploadRequest() {

0 commit comments

Comments
 (0)