change param name

This commit is contained in:
Jicheng Lu 2024-08-08 13:37:07 -05:00
parent 32e1da62c0
commit 1abf3f4aae
3 changed files with 18 additions and 17 deletions

View file

@ -4,6 +4,19 @@ namespace BotSharp.Abstraction.Files;
public interface IFileStorageService
{
#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
#region Conversation
/// <summary>
/// Get the message file screenshots for specific content types, e.g., pdf
@ -38,20 +51,9 @@ public interface IFileStorageService
bool DeleteConversationFiles(IEnumerable<string> conversationIds);
#endregion
#region User
string GetUserAvatar();
bool SaveUserAvatar(BotSharpFile file);
#endregion
#region Common
string GetDirectory(string conversationId);
byte[] GetFileBytes(string filePath);
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
}

View file

@ -14,9 +14,9 @@ public partial class LocalFileStorageService
return dir;
}
public byte[] GetFileBytes(string filePath)
public byte[] GetFileBytes(string fileStorageUrl)
{
using var stream = File.OpenRead(filePath);
using var stream = File.OpenRead(fileStorageUrl);
var bytes = new byte[stream.Length];
stream.Read(bytes, 0, (int)stream.Length);
return bytes;

View file

@ -7,12 +7,11 @@ public partial class TencentCosService
return $"{CONVERSATION_FOLDER}/{conversationId}/attachments/";
}
public byte[] GetFileBytes(string filePath)
public byte[] GetFileBytes(string fileStorageUrl)
{
try
{
var fileData = _cosClient.BucketClient.DownloadFileBytes(filePath);
return fileData;
return _cosClient.BucketClient.DownloadFileBytes(fileStorageUrl);
}
catch (Exception ex)
{