2023-11-22 15:44:25 -05:00
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
using static System.Text.Json.Serialization.JsonNumberHandling;
|
2020-11-02 15:55:49 -05:00
|
|
|
|
|
2023-04-18 14:05:17 +02:00
|
|
|
|
namespace Bit.Core.Tools.Models.Data;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2023-11-22 15:44:25 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A file secret being sent.
|
|
|
|
|
|
/// </summary>
|
2020-11-02 15:55:49 -05:00
|
|
|
|
public class SendFileData : SendData
|
|
|
|
|
|
{
|
2023-11-22 15:44:25 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Instantiates a <see cref="SendFileData"/>.
|
|
|
|
|
|
/// </summary>
|
2020-11-02 15:55:49 -05:00
|
|
|
|
public SendFileData() { }
|
|
|
|
|
|
|
2023-11-22 15:44:25 -05:00
|
|
|
|
/// <inheritdoc cref="SendFileData()"/>
|
|
|
|
|
|
/// <param name="name">Attached file name.</param>
|
|
|
|
|
|
/// <param name="notes">User-provided private notes of the send.</param>
|
|
|
|
|
|
/// <param name="fileName">Attached file name.</param>
|
|
|
|
|
|
public SendFileData(string name, string? notes, string fileName)
|
2022-01-21 09:36:25 -05:00
|
|
|
|
: base(name, notes)
|
|
|
|
|
|
{
|
|
|
|
|
|
FileName = fileName;
|
|
|
|
|
|
}
|
2020-11-02 15:55:49 -05:00
|
|
|
|
|
2023-11-22 15:44:25 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Size of the attached file in bytes.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// Serialized as a string since JSON (or Javascript) doesn't support
|
|
|
|
|
|
/// full precision for long numbers
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
[JsonNumberHandling(WriteAsString | AllowReadingFromString)]
|
2022-01-21 09:36:25 -05:00
|
|
|
|
public long Size { get; set; }
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2023-11-22 15:44:25 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Uniquely identifies an uploaded file.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>
|
|
|
|
|
|
/// Should contain <see langword="null" /> only when a file
|
|
|
|
|
|
/// upload is pending. Should never contain null once the
|
|
|
|
|
|
/// file upload completes.
|
|
|
|
|
|
/// </value>
|
|
|
|
|
|
[DisallowNull]
|
|
|
|
|
|
public string? Id { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Attached file name.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>
|
|
|
|
|
|
/// Should contain a non-empty string once the file upload completes.
|
|
|
|
|
|
/// </value>
|
|
|
|
|
|
public string FileName { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// When true the uploaded file's length was confirmed within
|
|
|
|
|
|
/// the expected tolerance and below the maximum supported
|
|
|
|
|
|
/// file size.
|
|
|
|
|
|
/// </summary>
|
2021-03-21 23:01:19 -05:00
|
|
|
|
public bool Validated { get; set; } = true;
|
2020-11-02 15:55:49 -05:00
|
|
|
|
}
|