|
|
@@ -48,7 +48,7 @@ namespace Quadarax.Application.TemporarySharedStorage.Client.Services
|
|
|
/// Progress is reported to the console in real-time showing percentage completion.
|
|
|
/// All errors are caught and displayed in a user-friendly format.
|
|
|
/// </remarks>
|
|
|
- public async Task UploadFileAsync(UploadFileRequest request)
|
|
|
+ public async Task<Tuple<string, TssResultEnum>> UploadFileAsync(UploadFileRequest request)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
@@ -59,7 +59,7 @@ namespace Quadarax.Application.TemporarySharedStorage.Client.Services
|
|
|
if (!fileInfo.Exists)
|
|
|
{
|
|
|
Log(LogSeverityEnum.Error, $"File '{request.FilePath}' not found");
|
|
|
- return;
|
|
|
+ return new Tuple<string, TssResultEnum>(string.Empty, TssResultEnum.FileNotFound);
|
|
|
}
|
|
|
|
|
|
Log(LogSeverityEnum.Info, $"File: {fileInfo.Name}, Size: {FormatFileSize(fileInfo.Length)}");
|
|
|
@@ -75,7 +75,7 @@ namespace Quadarax.Application.TemporarySharedStorage.Client.Services
|
|
|
if (initResponse == null || string.IsNullOrEmpty(initResponse.UploadId))
|
|
|
{
|
|
|
Log(LogSeverityEnum.Error, "Failed to initialize upload");
|
|
|
- return;
|
|
|
+ return new Tuple<string, TssResultEnum>(string.Empty, TssResultEnum.InitUploadFailed);
|
|
|
}
|
|
|
|
|
|
Log(LogSeverityEnum.Debug, $"Upload initialized with ID: {initResponse.UploadId}");
|
|
|
@@ -93,7 +93,7 @@ namespace Quadarax.Application.TemporarySharedStorage.Client.Services
|
|
|
if (!uploadSuccess)
|
|
|
{
|
|
|
Log(LogSeverityEnum.Error, "Failed to upload chunks");
|
|
|
- return;
|
|
|
+ return new Tuple<string, TssResultEnum>(string.Empty, TssResultEnum.UploadChunkFailed);
|
|
|
}
|
|
|
|
|
|
Log(LogSeverityEnum.Info, "All chunks uploaded successfully");
|
|
|
@@ -124,15 +124,18 @@ namespace Quadarax.Application.TemporarySharedStorage.Client.Services
|
|
|
Log(LogSeverityEnum.Info, $"File ID: {finalizeResponse.FileId}");
|
|
|
Log(LogSeverityEnum.Info, $"Permalink: {finalizeResponse.Permalink}");
|
|
|
Log(LogSeverityEnum.Debug, $"Shortcode: {finalizeResponse.Shortcode}");
|
|
|
+ return new Tuple<string, TssResultEnum>(finalizeResponse.FileId, TssResultEnum.Success);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Log(LogSeverityEnum.Error,"Failed to finalize upload");
|
|
|
+ return new Tuple<string, TssResultEnum>(string.Empty, TssResultEnum.UploadFinalizeFailed);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log(LogSeverityEnum.Error,"Internal error. See exception:", ex);
|
|
|
+ return new Tuple<string, TssResultEnum>(string.Empty, TssResultEnum.GeneralFailure);
|
|
|
}
|
|
|
}
|
|
|
|