BotSharp/src/Infrastructure/BotSharp.Abstraction/Files/IFileStorageService.cs

64 lines
2.7 KiB
C#
Raw Normal View History

2024-07-30 16:32:21 +00:00
using System.IO;
2024-05-06 06:51:59 +00:00
namespace BotSharp.Abstraction.Files;
2023-11-09 21:11:36 +00:00
2024-08-08 01:56:29 +00:00
public interface IFileStorageService
2023-11-09 21:11:36 +00:00
{
2024-08-08 18:37:07 +00:00
#region Common
string GetDirectory(string conversationId);
byte[] GetFileBytes(string fileStorageUrl);
bool SaveFileStreamToPath(string filePath, Stream stream);
bool SaveFileBytesToPath(string filePath, byte[] bytes);
string GetParentDir(string dir, int level = 1);
bool ExistDirectory(string? dir);
void CreateDirectory(string dir);
void DeleteDirectory(string dir);
string BuildDirectory(params string[] segments);
#endregion
2024-07-18 20:17:40 +00:00
#region Conversation
2024-07-17 19:28:29 +00:00
/// <summary>
2024-08-08 18:34:50 +00:00
/// Get the message file screenshots for specific content types, e.g., pdf
2024-07-17 19:28:29 +00:00
/// </summary>
/// <param name="conversationId"></param>
2024-08-08 18:34:50 +00:00
/// <param name="messageIds"></param>
2024-07-17 19:28:29 +00:00
/// <returns></returns>
2024-08-08 18:34:50 +00:00
Task<IEnumerable<MessageFileModel>> GetMessageFileScreenshots(string conversationId, IEnumerable<string> messageIds);
2024-07-17 19:28:29 +00:00
2024-07-18 20:17:40 +00:00
/// <summary>
/// Get the files that have been uploaded in the chat. No screenshot images are included.
/// </summary>
/// <param name="conversationId"></param>
/// <param name="messageIds"></param>
/// <param name="source"></param>
/// <param name="imageOnly"></param>
/// <returns></returns>
2024-08-07 21:56:57 +00:00
IEnumerable<MessageFileModel> GetMessageFiles(string conversationId, IEnumerable<string> messageIds, string source, IEnumerable<string>? contentTypes = null);
2024-06-06 19:57:41 +00:00
string GetMessageFile(string conversationId, string messageId, string source, string index, string fileName);
2024-07-08 22:37:22 +00:00
IEnumerable<MessageFileModel> GetMessagesWithFile(string conversationId, IEnumerable<string> messageIds);
2024-06-06 19:57:41 +00:00
bool SaveMessageFiles(string conversationId, string messageId, string source, List<BotSharpFile> files);
2024-05-22 04:33:31 +00:00
2024-05-06 22:31:52 +00:00
/// <summary>
/// Delete files under messages
/// </summary>
/// <param name="conversationId">Conversation Id</param>
/// <param name="messageIds">Files in these messages will be deleted</param>
/// <param name="targetMessageId">The starting message to delete</param>
/// <param name="newMessageId">If not null, delete messages while input a new message; otherwise, delete messages only</param>
/// <returns></returns>
bool DeleteMessageFiles(string conversationId, IEnumerable<string> messageIds, string targetMessageId, string? newMessageId = null);
bool DeleteConversationFiles(IEnumerable<string> conversationIds);
2024-07-18 20:17:40 +00:00
#endregion
2024-08-08 18:37:07 +00:00
2024-07-18 20:17:40 +00:00
#region User
string GetUserAvatar();
bool SaveUserAvatar(BotSharpFile file);
#endregion
2024-08-08 19:54:32 +00:00
#region Speech
Task SaveSpeechFileAsync(string conversationId, string fileName, BinaryData data);
Task<BinaryData> RetrieveSpeechFileAsync(string conversationId, string fileName);
#endregion
2023-11-09 21:11:36 +00:00
}