87 lines
2.5 KiB
C#
87 lines
2.5 KiB
C#
using System;
|
|
|
|
namespace FrostFS.SDK;
|
|
|
|
public class FrostFsObject
|
|
{
|
|
// private byte[]? _payloadBytes;
|
|
// private ReadOnlyMemory<byte> _payloadMemory;
|
|
// private bool _isInitPayloadMemory;
|
|
|
|
/// <summary>
|
|
/// Creates new instance from <c>ObjectHeader</c>
|
|
/// </summary>
|
|
/// <param name="header"></param> <summary>
|
|
public FrostFsObject(FrostFsObjectHeader header)
|
|
{
|
|
Header = header;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates new instance with specified parameters
|
|
/// </summary>
|
|
/// <param name="container"></param>
|
|
/// <param name="objectType"></param>
|
|
public FrostFsObject(FrostFsContainerId container, FrostFsObjectType objectType = FrostFsObjectType.Regular)
|
|
{
|
|
Header = new FrostFsObjectHeader(containerId: container, type: objectType);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Header contains metadata for the object
|
|
/// </summary>
|
|
/// <value></value>
|
|
public FrostFsObjectHeader Header { get; set; }
|
|
|
|
/// <summary>
|
|
/// The value is calculated internally as a hash of ObjectHeader. Do not use pre-calculated value is the object has been changed.
|
|
/// </summary>
|
|
public FrostFsObjectId? ObjectId
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// A payload is obtained via stream reader
|
|
/// </summary>
|
|
/// <value>Reader for received data</value>
|
|
public IObjectReader? ObjectReader { get; set; }
|
|
|
|
public ReadOnlyMemory<byte> SingleObjectPayload { get; set; }
|
|
|
|
//public ReadOnlyMemory<byte> SingleObjectPayloadMemory
|
|
//{
|
|
// get
|
|
// {
|
|
// if (!_isInitPayloadMemory)
|
|
// {
|
|
// _payloadMemory = _payloadBytes.AsMemory();
|
|
// _isInitPayloadMemory = true;
|
|
// }
|
|
|
|
// return _payloadMemory;
|
|
// }
|
|
// set
|
|
// {
|
|
// _payloadMemory = value;
|
|
// _isInitPayloadMemory = true;
|
|
// }
|
|
//}
|
|
|
|
/// <summary>
|
|
/// Provide SHA256 hash of the payload. If null, the hash is calculated by internal logic
|
|
/// </summary>
|
|
public byte[]? PayloadHash { get; set; }
|
|
|
|
/// <summary>
|
|
/// Applied only for the last Object in chain in case of manual multipart uploading
|
|
/// </summary>
|
|
/// <param name="largeObject">Parent for multipart object</param>
|
|
public void SetParent(FrostFsObjectHeader largeObjectHeader)
|
|
{
|
|
if (Header?.Split == null)
|
|
throw new ArgumentNullException(nameof(largeObjectHeader), "Split value must not be null");
|
|
|
|
Header.Split.ParentHeader = largeObjectHeader;
|
|
}
|
|
}
|