parent
c42497d68b
commit
e86bc4bec8
|
|
@ -45,12 +45,13 @@ namespace HeBianGu.App.Disk
|
|||
{
|
||||
setting.TaskCount = 3;
|
||||
}
|
||||
|
||||
//minioService.MirrorAsync1(bucketName, setting.SyncDir, setting.TaskCount);
|
||||
// 是否启监听
|
||||
if (SyncSetting.Instance.IsOn)
|
||||
{
|
||||
minioService.MirrorAsync1(bucketName, setting.SyncDir, setting.TaskCount);
|
||||
minioService.RealTimeListen(bucketName, setting.SyncDir);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,6 +140,7 @@ namespace HeBianGu.App.Disk
|
|||
base.Configure(app);
|
||||
app.UseSetting(x =>
|
||||
{
|
||||
x.Settings.Clear();
|
||||
x.Settings.Add(MySetting.Instance);
|
||||
x.Settings.Add(SyncSetting.Instance);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Channels;
|
||||
using HeBianGu.App.Disk;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Minio;
|
||||
using Minio.DataModel.Args;
|
||||
|
|
@ -329,15 +330,19 @@ namespace Hopetry.Services
|
|||
await DownLoadObject(item.bucketName, item.objectKey, item.localDir, item.objectETag);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
#region 监听事件
|
||||
|
||||
try
|
||||
{
|
||||
var events = new List<EventType> { EventType.ObjectCreatedAll };
|
||||
ListenBucketNotificationsArgs args = new ListenBucketNotificationsArgs()
|
||||
var args = new ListenBucketNotificationsArgs()
|
||||
.WithBucket(bucketName)
|
||||
.WithEvents(events);
|
||||
|
||||
IObservable<MinioNotificationRaw> observable = _minioClient.ListenBucketNotificationsAsync(args);
|
||||
IDisposable subscription = observable.Subscribe(
|
||||
var subscription = observable.Subscribe(
|
||||
async notification =>
|
||||
{
|
||||
Console.WriteLine($"Received notification: {notification.Json}");
|
||||
|
|
@ -348,6 +353,7 @@ namespace Hopetry.Services
|
|||
var objectKey = obj["Records"]?[0]?["s3"]?["object"]?["key"]?.Value<string>();
|
||||
var objectETag = obj["Records"]?[0]?["s3"]?["object"]?["eTag"]?.Value<string>();
|
||||
Console.WriteLine("将要下载的Key:" + objectKey);
|
||||
// 字段值不会为空
|
||||
downloadQueue.Writer.TryWrite((bucketName, objectKey, localDir, objectETag));
|
||||
//await DownLoadObject(bucketName, objectKey, localDir, objectETag);
|
||||
},
|
||||
|
|
@ -358,6 +364,8 @@ namespace Hopetry.Services
|
|||
{
|
||||
Console.WriteLine("Error occurred: " + e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,6 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Channels;
|
||||
using System.Windows.Threading;
|
||||
using FileUploader.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Minio;
|
||||
using Minio.ApiEndpoints;
|
||||
using System.IO;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.DataModel.Notification;
|
||||
using Minio.Exceptions;
|
||||
|
||||
namespace Hopetry.Services
|
||||
{
|
||||
|
|
@ -22,7 +12,7 @@ namespace Hopetry.Services
|
|||
try
|
||||
{
|
||||
string bucketName = "test";
|
||||
string objectName = System.IO.Path.GetFileName(filePath);
|
||||
string objectName = Path.GetFileName(filePath);
|
||||
|
||||
//判断桶是否存在
|
||||
var beArgs = new BucketExistsArgs().WithBucket(bucketName);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"Minio": {
|
||||
"Endpoint": "123.132.248.154:9107",
|
||||
"AccessKey": "oZNgo25pNXnKFV9oKGh4",
|
||||
"SecretKey": "66GYn0x1XAEInSa9wdCutzvUWKfhH1EhqxPJ6a9u",
|
||||
"BucketName": "demo"
|
||||
"Endpoint": "192.168.20.239:9000",
|
||||
"AccessKey": "cqlatqb0dgqdBRar7KVF",
|
||||
"SecretKey": "FUFzd5VeoBeWhrpql6MBON5tQxNzcIgaK7vkvofX",
|
||||
"BucketName": "drone"
|
||||
}
|
||||
}
|
||||
/*{
|
||||
|
|
|
|||
Loading…
Reference in New Issue