mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Workshop - Simplify upload to a busy indicator, show images in profiles
This commit is contained in:
1 parent
e33ae8a066
commit
e304d67035
22 files changed
+125
-242
No files matched your search
@@ -4,5 +4,5 @@ namespace Artemis.WebClient.Workshop.Handlers.UploadHandlers;
|
||||
|
||||
public interface IEntryUploadHandler
|
||||
{
|
||||
Task<EntryUploadResult> CreateReleaseAsync(long entryId, IEntrySource entrySource, Progress<StreamProgress> progress, CancellationToken cancellationToken);
|
||||
Task<EntryUploadResult> CreateReleaseAsync(long entryId, IEntrySource entrySource, CancellationToken cancellationToken);
|
||||
}
|
||||
+2
-2
@@ -19,7 +19,7 @@ public class LayoutEntryUploadHandler : IEntryUploadHandler
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<EntryUploadResult> CreateReleaseAsync(long entryId, IEntrySource entrySource, Progress<StreamProgress> progress, CancellationToken cancellationToken)
|
||||
public async Task<EntryUploadResult> CreateReleaseAsync(long entryId, IEntrySource entrySource, CancellationToken cancellationToken)
|
||||
{
|
||||
if (entrySource is not LayoutEntrySource source)
|
||||
throw new InvalidOperationException("Can only create releases for layouts");
|
||||
@@ -67,7 +67,7 @@ public class LayoutEntryUploadHandler : IEntryUploadHandler
|
||||
|
||||
// Construct the request
|
||||
MultipartFormDataContent content = new();
|
||||
ProgressableStreamContent streamContent = new(archiveStream, progress);
|
||||
StreamContent streamContent = new(archiveStream);
|
||||
streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
|
||||
content.Add(streamContent, "file", "file.zip");
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ public class ProfileEntryUploadHandler : IEntryUploadHandler
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<EntryUploadResult> CreateReleaseAsync(long entryId, IEntrySource entrySource, Progress<StreamProgress> progress, CancellationToken cancellationToken)
|
||||
public async Task<EntryUploadResult> CreateReleaseAsync(long entryId, IEntrySource entrySource, CancellationToken cancellationToken)
|
||||
{
|
||||
if (entrySource is not ProfileEntrySource source)
|
||||
throw new InvalidOperationException("Can only create releases for profile configurations");
|
||||
@@ -30,7 +30,7 @@ public class ProfileEntryUploadHandler : IEntryUploadHandler
|
||||
|
||||
// Construct the request
|
||||
MultipartFormDataContent content = new();
|
||||
ProgressableStreamContent streamContent = new(archiveStream, progress);
|
||||
StreamContent streamContent = new(archiveStream);
|
||||
streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
|
||||
content.Add(streamContent, "file", "file.zip");
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Artemis.WebClient.Workshop.Services;
|
||||
public interface IWorkshopService
|
||||
{
|
||||
Task<Stream?> GetEntryIcon(long entryId, CancellationToken cancellationToken);
|
||||
Task<ImageUploadResult> SetEntryIcon(long entryId, Progress<StreamProgress> progress, Stream icon, CancellationToken cancellationToken);
|
||||
Task<ImageUploadResult> UploadEntryImage(long entryId, ImageUploadRequest request, Progress<StreamProgress> progress, CancellationToken cancellationToken);
|
||||
Task<ImageUploadResult> SetEntryIcon(long entryId, Stream icon, CancellationToken cancellationToken);
|
||||
Task<ImageUploadResult> UploadEntryImage(long entryId, ImageUploadRequest request, CancellationToken cancellationToken);
|
||||
Task<WorkshopStatus> GetWorkshopStatus(CancellationToken cancellationToken);
|
||||
Task<bool> ValidateWorkshopStatus(CancellationToken cancellationToken);
|
||||
Task NavigateToEntry(long entryId, EntryType entryType);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class WorkshopService : IWorkshopService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ImageUploadResult> SetEntryIcon(long entryId, Progress<StreamProgress> progress, Stream icon, CancellationToken cancellationToken)
|
||||
public async Task<ImageUploadResult> SetEntryIcon(long entryId, Stream icon, CancellationToken cancellationToken)
|
||||
{
|
||||
icon.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WorkshopService : IWorkshopService
|
||||
|
||||
// Construct the request
|
||||
MultipartFormDataContent content = new();
|
||||
ProgressableStreamContent streamContent = new(icon, progress);
|
||||
StreamContent streamContent = new(icon);
|
||||
streamContent.Headers.ContentType = new MediaTypeHeaderValue("image/png");
|
||||
content.Add(streamContent, "file", "file.png");
|
||||
|
||||
@@ -57,7 +57,7 @@ public class WorkshopService : IWorkshopService
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<ImageUploadResult> UploadEntryImage(long entryId, ImageUploadRequest request, Progress<StreamProgress> progress, CancellationToken cancellationToken)
|
||||
public async Task<ImageUploadResult> UploadEntryImage(long entryId, ImageUploadRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
request.File.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class WorkshopService : IWorkshopService
|
||||
|
||||
// Construct the request
|
||||
MultipartFormDataContent content = new();
|
||||
ProgressableStreamContent streamContent = new(request.File, progress);
|
||||
StreamContent streamContent = new(request.File);
|
||||
streamContent.Headers.ContentType = new MediaTypeHeaderValue("image/png");
|
||||
content.Add(streamContent, "file", "file.png");
|
||||
content.Add(new StringContent(request.Name), "Name");
|
||||
|
||||
Reference in new issue
Block a user