fix file save
This commit is contained in:
parent
f12550a440
commit
eb679701bd
|
|
@ -16,6 +16,11 @@ public partial class ConversationService
|
|||
{
|
||||
var conversation = await GetConversationRecord(agentId);
|
||||
|
||||
// Save message files
|
||||
var fileService = _services.GetRequiredService<IBotSharpFileService>();
|
||||
fileService.SaveMessageFiles(_conversationId, message.MessageId, FileSourceType.User, message.Files);
|
||||
message.Files?.Clear();
|
||||
|
||||
var agentService = _services.GetRequiredService<IAgentService>();
|
||||
Agent agent = await agentService.LoadAgent(agentId);
|
||||
|
||||
|
|
@ -46,11 +51,6 @@ public partial class ConversationService
|
|||
routing.Context.SetMessageId(_conversationId, message.MessageId);
|
||||
routing.Context.Push(agent.Id);
|
||||
|
||||
// Save message files
|
||||
var fileService = _services.GetRequiredService<IBotSharpFileService>();
|
||||
fileService.SaveMessageFiles(_conversationId, message.MessageId, FileSourceType.User, message.Files);
|
||||
message.Files?.Clear();
|
||||
|
||||
// Save payload
|
||||
if (replyMessage != null && !string.IsNullOrEmpty(replyMessage.Payload))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Amazon.Runtime.Internal.Auth;
|
||||
using BotSharp.Abstraction.Browsing;
|
||||
using BotSharp.Abstraction.Browsing.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
@ -221,14 +222,16 @@ public partial class BotSharpFileService
|
|||
}
|
||||
|
||||
var (_, bytes) = GetFileInfoFromData(file.FileData);
|
||||
Thread.Sleep(100);
|
||||
var subDir = Path.Combine(dir, source, $"{i + 1}");
|
||||
if (!ExistDirectory(subDir))
|
||||
{
|
||||
Directory.CreateDirectory(subDir);
|
||||
}
|
||||
|
||||
File.WriteAllBytes(Path.Combine(subDir, file.FileName), bytes);
|
||||
using var fs = new FileStream(Path.Combine(subDir, file.FileName), FileMode.OpenOrCreate);
|
||||
fs.Write(bytes, 0, bytes.Length);
|
||||
fs.Flush();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue