Use attachment filename if available.

pull/1838/head
Andrew Mahone 5 years ago
parent 01b1c847e9
commit 20727906c8

@ -20,7 +20,7 @@ using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
namespace MediaBrowser.Api.Attachments
{
[Route("/Videos/{Id}/{MediaSourceId}/Attachments/{Index}/Attachment", "GET", Summary = "Gets specified attachment.")]
[Route("/Videos/{Id}/{MediaSourceId}/Attachments/{Index}/{Filename}", "GET", Summary = "Gets specified attachment.")]
public class GetAttachment
{
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
@ -31,6 +31,9 @@ namespace MediaBrowser.Api.Attachments
[ApiMember(Name = "Index", Description = "The attachment stream index", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")]
public int Index { get; set; }
[ApiMember(Name = "Filename", Description = "The attachment filename", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Filename { get; set; }
}
public class AttachmentService : BaseApiService

@ -527,10 +527,12 @@ namespace MediaBrowser.Api.Playback
foreach (var attachment in mediaSource.MediaAttachments)
{
attachment.DeliveryUrl = string.Format("/Videos/{0}/{1}/Attachments/{2}/Attachment",
var filename = string.IsNullOrWhiteSpace(attachment.Filename) ? "Attachment" : attachment.Filename;
attachment.DeliveryUrl = string.Format("/Videos/{0}/{1}/Attachments/{2}/{3}",
item.Id,
mediaSource.Id,
attachment.Index);
attachment.Index,
filename);
}
}

Loading…
Cancel
Save