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:
commit
abb18028f9
EftPatchHelper/EftPatchHelper
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace EftPatchHelper.Tasks
|
||||
|
||||
if(_settings.UsingGoFile() && _options.UploadToGoFile)
|
||||
{
|
||||
var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey);
|
||||
var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey, _settings.GoFileFolderId);
|
||||
_fileUploads.Add(gofile);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
"giteaReleaseRepoName": "",
|
||||
"megaEmail": "",
|
||||
"megaPassword": "",
|
||||
"megaUploadFolder": "",
|
||||
"goFileApiKey": ""
|
||||
"megaUploadFolder": "",
|
||||
"goFileApiKey": "",
|
||||
"goFileFolderId": ""
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user