-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support to download documents
- Loading branch information
Showing
7 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
source/VMelnalksnis.PaperlessDotNet/Documents/DocumentContent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2022 Valters Melnalksnis | ||
// Licensed under the Apache License 2.0. | ||
// See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Net.Http.Headers; | ||
|
||
namespace VMelnalksnis.PaperlessDotNet.Documents; | ||
|
||
/// <summary> | ||
/// The downloaded content of a document. | ||
/// </summary> | ||
public sealed class DocumentContent : IDisposable | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="DocumentContent"/> class.</summary> | ||
/// <param name="content">The document content.</param> | ||
/// <param name="contentDisposition">The ContentDisposition header of the download.</param> | ||
/// <param name="mediaTypeHeaderValue">The MediaType header of the download.</param> | ||
public DocumentContent(Stream content, ContentDispositionHeaderValue? contentDisposition, MediaTypeHeaderValue mediaTypeHeaderValue) | ||
{ | ||
Content = content; | ||
ContentDisposition = contentDisposition; | ||
MediaTypeHeaderValue = mediaTypeHeaderValue; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the document content. | ||
/// </summary> | ||
public Stream Content { get; } | ||
|
||
/// <summary> | ||
/// Gets the ContentDisposition header of the download. | ||
/// </summary> | ||
public ContentDispositionHeaderValue? ContentDisposition { get; } | ||
|
||
/// <summary> | ||
/// Gets the MediaType header of the download. | ||
/// </summary> | ||
public MediaTypeHeaderValue MediaTypeHeaderValue { get; } | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() => Content.Dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/VMelnalksnis.PaperlessDotNet.Tests.Integration/Documents/Lorem Ipsum 3.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi interdum libero at augue sagittis, ut aliquam arcu fringilla. Aenean elit nibh, blandit eu lacinia id, fermentum vitae sapien. Nunc efficitur cursus tempus. Phasellus consequat diam non ante pulvinar dapibus. Pellentesque ullamcorper nulla quis purus laoreet fringilla. Pellentesque vitae elit dolor. Nam elementum a leo non elementum. Cras non ante efficitur, molestie neque a, ultrices leo. Duis mollis ex fringilla elit lacinia semper. Nulla orci tellus, tristique sed iaculis non, sagittis a sem. Aenean scelerisque laoreet erat, a congue urna faucibus mollis. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters