添加未上传完查询测试
parent
3c35d15148
commit
930bc6675f
|
|
@ -13,6 +13,7 @@ Title="test" Height="450" Width="800">
|
|||
<ProgressBar Name="progressBar" HorizontalAlignment="Left" Height="10" Margin="177,277,0,0" VerticalAlignment="Top" Width="100" ValueChanged="progressBar_ValueChanged"/>
|
||||
<TextBox Name="StatusText" HorizontalAlignment="Left" Margin="385,328,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
|
||||
<CheckBox Name="ShutdownCheckBox" Content="是否上传完毕关机" HorizontalAlignment="Left" Margin="505,181,0,0" VerticalAlignment="Top"/>
|
||||
<ui:Button Content="测试断点续传" HorizontalAlignment="Left" Margin="137,345,0,0" VerticalAlignment="Top" Click="Button_Click_1"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
|
|
|||
49
test.xaml.cs
49
test.xaml.cs
|
|
@ -19,6 +19,9 @@ using Minio.DataModel.Encryption;
|
|||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using Minio.Exceptions;
|
||||
using System.Threading;
|
||||
using System.Security.AccessControl;
|
||||
namespace Hopetry
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -30,6 +33,7 @@ namespace Hopetry
|
|||
public test()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 配置 MinIO 客户端
|
||||
client = new Minio.MinioClient()
|
||||
.WithEndpoint("123.132.248.154:9107") // MinIO 服务器地址
|
||||
|
|
@ -215,6 +219,51 @@ namespace Hopetry
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
private async void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string bucketName = "test";
|
||||
|
||||
// 检查存储桶是否存在,如果不存在则创建
|
||||
var beArgs = new BucketExistsArgs().WithBucket(bucketName);
|
||||
// Check whether 'mybucket' exist or not.
|
||||
bool found = await client.BucketExistsAsync(beArgs).ConfigureAwait(false);
|
||||
if (found)
|
||||
{
|
||||
// List all incomplete multipart upload of objects in 'mybucket'
|
||||
ListIncompleteUploadsArgs listArgs = new ListIncompleteUploadsArgs()
|
||||
.WithBucket("test")
|
||||
.WithRecursive(true);
|
||||
IAsyncEnumerable<Upload> observable = client.ListIncompleteUploadsEnumAsync(listArgs);
|
||||
//IDisposable subscription = observable.Subscribe(
|
||||
// item => Console.WriteLine("OnNext: {0}", item.Key),
|
||||
// ex => Console.WriteLine("OnError: {0}", ex.Message),
|
||||
// () => Console.WriteLine("OnComplete: {0}"));
|
||||
|
||||
await foreach (var upload in observable)
|
||||
{
|
||||
// 在这里查看每个 Upload 对象
|
||||
Console.WriteLine($"Upload ID: {upload.UploadId}, Object Name: {upload.Key}");
|
||||
var statObjectArgs = new StatObjectArgs()
|
||||
.WithBucket(bucketName)
|
||||
.WithObject(upload.Key);
|
||||
|
||||
// Get object metadata if it exists
|
||||
var objectStat = await client.StatObjectAsync(statObjectArgs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("mybucket does not exist");
|
||||
}
|
||||
}
|
||||
catch (MinioException ex)
|
||||
{
|
||||
Console.WriteLine("Error occurred: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue