Merge pull request #572 from iceljc/bugfix/fix-audio-file-range
fix audio range request
This commit is contained in:
commit
42280eea7d
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
namespace BotSharp.Abstraction.Files.Constants;
|
||||
|
||||
public class FileConstants
|
||||
{
|
||||
public static readonly IEnumerable<string> AudioExtensions = new List<string>
|
||||
{
|
||||
".mp3", ".wav", ".flac", ".aac", ".ogg", ".wma"
|
||||
};
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Files.Constants;
|
||||
using BotSharp.Abstraction.Files.Enums;
|
||||
using BotSharp.Abstraction.Options;
|
||||
using BotSharp.Abstraction.Routing;
|
||||
|
|
@ -413,7 +414,9 @@ public class ConversationController : ControllerBase
|
|||
using Stream stream = System.IO.File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
var bytes = new byte[stream.Length];
|
||||
stream.Read(bytes, 0, (int)stream.Length);
|
||||
return File(bytes, "application/octet-stream", Path.GetFileName(file));
|
||||
var fileExtension = Path.GetExtension(file).ToLower();
|
||||
var enableRangeProcessing = FileConstants.AudioExtensions.Contains(fileExtension);
|
||||
return File(bytes, "application/octet-stream", Path.GetFileName(file), enableRangeProcessing: enableRangeProcessing);
|
||||
}
|
||||
|
||||
private async Task OnChunkReceived(HttpResponse response, ChatResponseModel message)
|
||||
|
|
|
|||
Loading…
Reference in a new issue