jellyfin/MediaBrowser.Common/Net/Handlers/BaseEmbeddedResourceHandler.cs

29 lines
789 B
C#
Raw Normal View History

2012-08-22 02:50:59 +00:00
using System.IO;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Net.Handlers
{
public abstract class BaseEmbeddedResourceHandler : BaseHandler
{
public BaseEmbeddedResourceHandler(string resourcePath)
: base()
{
ResourcePath = resourcePath;
}
protected string ResourcePath { get; set; }
public override Task<string> GetContentType()
{
2012-08-22 02:50:59 +00:00
return Task.FromResult<string>(MimeTypes.GetMimeType(ResourcePath));
}
protected override Task WriteResponseToOutputStream(Stream stream)
{
return GetEmbeddedResourceStream().CopyToAsync(stream);
}
protected abstract Stream GetEmbeddedResourceStream();
}
}