🧱 Grpc service basis

This commit is contained in:
2025-07-12 15:19:31 +08:00
parent 0318364bcf
commit 33f56c4ef5
28 changed files with 1620 additions and 28 deletions

View File

@ -1,3 +1,5 @@
using Google.Protobuf.WellKnownTypes;
namespace DysonNetwork.Shared.Data;
/// <summary>
@ -14,4 +16,43 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile
public string? Hash { get; set; }
public long Size { get; set; }
public bool HasCompression { get; set; } = false;
/// <summary>
/// Converts the current object to its protobuf representation
/// </summary>
public global::DysonNetwork.Shared.Proto.CloudFileReferenceObject ToProtoValue()
{
var proto = new global::DysonNetwork.Shared.Proto.CloudFileReferenceObject
{
Id = Id,
Name = Name,
MimeType = MimeType ?? string.Empty,
Hash = Hash ?? string.Empty,
Size = Size,
HasCompression = HasCompression,
// Backward compatibility fields
ContentType = MimeType ?? string.Empty,
Url = string.Empty // This should be set by the caller if needed
};
// Convert file metadata
if (FileMeta != null)
{
foreach (var (key, value) in FileMeta)
{
proto.FileMeta[key] = Value.ForString(value?.ToString() ?? string.Empty);
}
}
// Convert user metadata
if (UserMeta != null)
{
foreach (var (key, value) in UserMeta)
{
proto.UserMeta[key] = Value.ForString(value?.ToString() ?? string.Empty);
}
}
return proto;
}
}