pull/3344/head
adechant 3 months ago
parent 3e45f27f5e
commit 24fa729e97

@ -1,3 +1,4 @@
import _ from 'lodash';
import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions';
import bookEntities from 'Book/bookEntities';
@ -206,7 +207,7 @@ export const actionHandlers = handleThunks({
const {
id: bookFileId
} = payload;
const downloadPromise = createAjaxRequest({
url: `/bookFile/download/${bookFileId}`,
method: 'GET'
@ -216,10 +217,10 @@ export const actionHandlers = handleThunks({
if ( textStatus === 'success') {
let fileName = 'download';
let ext = '.unknown';
let contentType = jqXHR.getResponseHeader('content-type');
const contentType = jqXHR.getResponseHeader('content-type');
ext = `.${contentType.substring(contentType.indexOf('/')+1)}`;
if (jqXHR.getResponseHeader('content-disposition')) {
var contentDisposition = jqXHR.getResponseHeader('content-disposition');
const contentDisposition = jqXHR.getResponseHeader('content-disposition');
if (contentDisposition.indexOf('=')>=0) {
fileName = contentDisposition.substring(contentDisposition.indexOf('=')+1);
ext='';

@ -125,16 +125,17 @@ namespace Readarr.Api.V1.BookFiles
[HttpGet("download/{id:int}")]
public IActionResult GetBookFile(int id)
{
var files = _mediaFileService.GetFilesByBook(id);
if (files.Empty())
try
{
throw new BadRequestException(string.Format("no bookfiles exist for book with id: {0}", id));
var bookFile = _mediaFileService.Get(id);
var filePath = bookFile.Path;
Response.Headers.Add("content-disposition", string.Format("attachment;filename={0}", PathExtensions.BaseName(filePath)));
return new PhysicalFileResult(filePath, GetContentType(filePath));
}
catch
{
throw new BadRequestException(string.Format("no bookfiles exist for id: {0}", id));
}
var bookFile = files.First();
var filePath = bookFile.Path;
Response.Headers.Add("content-disposition", string.Format("attachment;filename={0}", PathExtensions.BaseName(filePath)));
return new PhysicalFileResult(filePath, GetContentType(filePath));
}
[HttpPost("upload/{id:int}")]

@ -227,17 +227,15 @@ namespace Readarr.Api.V1.OPDS
if (files.Count > 0)
{
//we'll only add the first bookfile (for now)
foreach (var file in files)
{
linkResources.Add(new OPDSLinkResource
{
Href = string.Format("bookfile/download/{0}", book.Id),
Href = string.Format("bookfile/download/{0}", file.Id),
Rel = "http://opds-spec.org/acquisition",
Title = string.Format("Readarr OPDS Link:{0}", book.Id),
Title = string.Format("Readarr OPDS Link:{0}", file.Id),
Type = GetContentType(file.Path)
});
break;
}
}
else if (edition != null)

Loading…
Cancel
Save