commit
c8d1427472
@ -2,16 +2,17 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyVersion>1.4.2</AssemblyVersion>
|
||||
<FileVersion>1.4.2</FileVersion>
|
||||
<AssemblyVersion>1.5.1</AssemblyVersion>
|
||||
<FileVersion>1.5.1</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FubarCoder.RestSharp.Portable.Core" Version="4.0.8" />
|
||||
<PackageReference Include="FubarCoder.RestSharp.Portable.HttpClient" Version="4.0.8" />
|
||||
<PackageReference Include="GoFileSharp" Version="1.0.2" />
|
||||
<PackageReference Include="MegaApiClient" Version="1.10.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||
@ -24,9 +25,6 @@
|
||||
<Reference Include="Gitea">
|
||||
<HintPath>Resources\Gitea.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="GoFileSharp">
|
||||
<HintPath>Resources\GoFileSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,12 +1,17 @@
|
||||
using EftPatchHelper.Interfaces;
|
||||
using GoFileSharp;
|
||||
using GoFileSharp.Model;
|
||||
using GoFileSharp.Model.GoFileData;
|
||||
using GoFileSharp.Model.GoFileData.Wrappers;
|
||||
|
||||
|
||||
namespace EftPatchHelper.Model
|
||||
{
|
||||
public class GoFileUpload : IFileUpload
|
||||
{
|
||||
private GoFile _goFile;
|
||||
public FileInfo UploadFileInfo { get; private set; }
|
||||
private DirectLink? _directLink = null;
|
||||
private GoFileFile _uploadedFile;
|
||||
private string _folderId;
|
||||
|
||||
@ -16,7 +21,11 @@ namespace EftPatchHelper.Model
|
||||
|
||||
public GoFileUpload(FileInfo file, string apiToken, string folderId)
|
||||
{
|
||||
GoFile.ApiToken = apiToken;
|
||||
_goFile = new GoFile(new GoFileOptions
|
||||
{
|
||||
ApiToken = apiToken
|
||||
});
|
||||
|
||||
_folderId = folderId;
|
||||
UploadFileInfo = file;
|
||||
ServiceName = "GoFile";
|
||||
@ -26,12 +35,12 @@ namespace EftPatchHelper.Model
|
||||
|
||||
public string GetLink()
|
||||
{
|
||||
return _uploadedFile.DirectLink;
|
||||
return _directLink?.Link ?? "";
|
||||
}
|
||||
|
||||
public async Task<bool> UploadAsync(IProgress<double>? progress = null)
|
||||
{
|
||||
var folder = await GoFile.GetFolder(_folderId);
|
||||
var folder = await _goFile.GetFolderAsync(_folderId);
|
||||
|
||||
if (folder == null)
|
||||
{
|
||||
@ -42,7 +51,9 @@ namespace EftPatchHelper.Model
|
||||
|
||||
if(uploadedFile == null) return false;
|
||||
|
||||
if(!await uploadedFile.SetDirectLink(true))
|
||||
_directLink = await uploadedFile.AddDirectLink();
|
||||
|
||||
if(_directLink == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user