From 47f84f5cd7759c1dd606bddca6b1e72946761588 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Thu, 20 Jul 2023 13:50:50 -0400 Subject: [PATCH] update gofile upload to use a folder id --- EftPatchHelper/EftPatchHelper/Model/GoFileUpload.cs | 13 +++++++++++-- EftPatchHelper/EftPatchHelper/Model/Settings.cs | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/EftPatchHelper/EftPatchHelper/Model/GoFileUpload.cs b/EftPatchHelper/EftPatchHelper/Model/GoFileUpload.cs index ae58d86..5ca5349 100644 --- a/EftPatchHelper/EftPatchHelper/Model/GoFileUpload.cs +++ b/EftPatchHelper/EftPatchHelper/Model/GoFileUpload.cs @@ -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 UploadAsync(IProgress? 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; diff --git a/EftPatchHelper/EftPatchHelper/Model/Settings.cs b/EftPatchHelper/EftPatchHelper/Model/Settings.cs index 0c7ad1d..9ff6cb6 100644 --- a/EftPatchHelper/EftPatchHelper/Model/Settings.cs +++ b/EftPatchHelper/EftPatchHelper/Model/Settings.cs @@ -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; }