mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
Simplify file returns
This commit is contained in:
parent
c473645f9d
commit
ec2a5e4fb0
5 changed files with 8 additions and 10 deletions
|
@ -215,8 +215,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
return Redirect("index.html?start=wizard#!/wizardstart.html");
|
return Redirect("index.html?start=wizard#!/wizardstart.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
var stream = new FileStream(_resourceFileManager.GetResourcePath(basePath, path), FileMode.Open, FileAccess.Read);
|
return PhysicalFile(_resourceFileManager.GetResourcePath(basePath, path), MimeTypes.GetMimeType(path));
|
||||||
return File(stream, MimeTypes.GetMimeType(path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -264,8 +264,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
var contentPath = await System.IO.File.ReadAllTextAsync(pointerCachePath).ConfigureAwait(false);
|
var contentPath = await System.IO.File.ReadAllTextAsync(pointerCachePath).ConfigureAwait(false);
|
||||||
if (System.IO.File.Exists(contentPath))
|
if (System.IO.File.Exists(contentPath))
|
||||||
{
|
{
|
||||||
await using var fileStreamExisting = System.IO.File.OpenRead(pointerCachePath);
|
return PhysicalFile(contentPath, MimeTypes.GetMimeType(contentPath));
|
||||||
return new FileStreamResult(fileStreamExisting, MediaTypeNames.Application.Octet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
catch (FileNotFoundException)
|
||||||
|
@ -278,7 +277,8 @@ namespace Jellyfin.Api.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
await DownloadImage(providerName, imageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
|
await DownloadImage(providerName, imageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
|
||||||
return PhysicalFile(pointerCachePath, MimeTypes.GetMimeType(pointerCachePath));
|
var updatedContentPath = await System.IO.File.ReadAllTextAsync(pointerCachePath).ConfigureAwait(false);
|
||||||
|
return PhysicalFile(updatedContentPath, MimeTypes.GetMimeType(updatedContentPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -114,8 +114,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
using var fileStream = new FileStream(item.Path, FileMode.Open, FileAccess.Read);
|
return PhysicalFile(item.Path, MimeTypes.GetMimeType(item.Path));
|
||||||
return File(fileStream, MimeTypes.GetMimeType(item.Path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -214,8 +214,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
var subtitleStream = mediaSource.MediaStreams
|
var subtitleStream = mediaSource.MediaStreams
|
||||||
.First(i => i.Type == MediaStreamType.Subtitle && i.Index == index);
|
.First(i => i.Type == MediaStreamType.Subtitle && i.Index == index);
|
||||||
|
|
||||||
FileStream stream = new FileStream(subtitleStream.Path, FileMode.Open, FileAccess.Read);
|
return PhysicalFile(subtitleStream.Path, MimeTypes.GetMimeType(subtitleStream.Path));
|
||||||
return File(stream, MimeTypes.GetMimeType(subtitleStream.Path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(format, "vtt", StringComparison.OrdinalIgnoreCase) && addVttTimeMap)
|
if (string.Equals(format, "vtt", StringComparison.OrdinalIgnoreCase) && addVttTimeMap)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.IO;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
Loading…
Reference in a new issue