update gofile upload to use a folder id

This commit is contained in:
IsWaffle 2023-07-20 13:50:50 -04:00
parent d51dd9b469
commit 47f84f5cd7
2 changed files with 16 additions and 2 deletions

View File

@ -8,14 +8,16 @@ namespace EftPatchHelper.Model
{
public FileInfo UploadFileInfo { get; private set; }
private GoFileFile _uploadedFile;
private string _folderId;
public string DisplayName { get; set; }
public string ServiceName { get; set; }
public string HubEntryText { get; set; }
public GoFileUpload(FileInfo file, string apiToken)
public GoFileUpload(FileInfo file, string apiToken, string folderId)
{
GoFile.ApiToken = apiToken;
_folderId = folderId;
UploadFileInfo = file;
ServiceName = "GoFile";
DisplayName = $"{ServiceName} Upload: {UploadFileInfo.Name}";
@ -29,7 +31,14 @@ namespace EftPatchHelper.Model
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;

View File

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