Merge pull request 'update gofile upload to use a folder id' (#3) from feature/gofile-specify-folder into main

Reviewed-on: #3
This commit is contained in:
IsWaffle 2023-07-21 01:56:45 +00:00
commit abb18028f9
4 changed files with 20 additions and 5 deletions

View File

@ -8,14 +8,16 @@ namespace EftPatchHelper.Model
{ {
public FileInfo UploadFileInfo { get; private set; } public FileInfo UploadFileInfo { get; private set; }
private GoFileFile _uploadedFile; private GoFileFile _uploadedFile;
private string _folderId;
public string DisplayName { get; set; } public string DisplayName { get; set; }
public string ServiceName { get; set; } public string ServiceName { get; set; }
public string HubEntryText { get; set; } public string HubEntryText { get; set; }
public GoFileUpload(FileInfo file, string apiToken) public GoFileUpload(FileInfo file, string apiToken, string folderId)
{ {
GoFile.ApiToken = apiToken; GoFile.ApiToken = apiToken;
_folderId = folderId;
UploadFileInfo = file; UploadFileInfo = file;
ServiceName = "GoFile"; ServiceName = "GoFile";
DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}"; DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}";
@ -29,7 +31,14 @@ namespace EftPatchHelper.Model
public async Task<bool> UploadAsync(IProgress<double>? progress = null) public async Task<bool> UploadAsync(IProgress<double>? progress = null)
{ {
var uploadedFile = await GoFile.UploadFileAsync(UploadFileInfo, progress); var folder = await GoFile.GetFolder(_folderId);
if (folder == null)
{
return false;
}
var uploadedFile = await folder.UploadIntoAsync(UploadFileInfo, progress);
if(uploadedFile == null) return false; if(uploadedFile == null) return false;

View File

@ -54,6 +54,9 @@ namespace EftPatchHelper.Model
[JsonPropertyName("goFileApiKey")] [JsonPropertyName("goFileApiKey")]
public string GoFileApiKey { get; set; } = ""; public string GoFileApiKey { get; set; } = "";
[JsonPropertyName("goFileFolderId")]
public string GoFileFolderId { get; set; } = "";
public bool Save() public bool Save()
{ {
try try
@ -103,6 +106,8 @@ namespace EftPatchHelper.Model
{ {
if (string.IsNullOrWhiteSpace(GoFileApiKey)) return false; if (string.IsNullOrWhiteSpace(GoFileApiKey)) return false;
if(string.IsNullOrWhiteSpace(GoFileFolderId)) return false;
return true; return true;
} }

View File

@ -38,7 +38,7 @@ namespace EftPatchHelper.Tasks
if(_settings.UsingGoFile() && _options.UploadToGoFile) if(_settings.UsingGoFile() && _options.UploadToGoFile)
{ {
var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey); var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey, _settings.GoFileFolderId);
_fileUploads.Add(gofile); _fileUploads.Add(gofile);
} }

View File

@ -12,6 +12,7 @@
"giteaReleaseRepoName": "", "giteaReleaseRepoName": "",
"megaEmail": "", "megaEmail": "",
"megaPassword": "", "megaPassword": "",
"megaUploadFolder": "", "megaUploadFolder": "",
"goFileApiKey": "" "goFileApiKey": "",
"goFileFolderId": ""
} }