✨ Remix file service
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace DysonNetwork.Shared.Data;
|
||||
@@ -10,13 +11,30 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public Dictionary<string, object>? FileMeta { get; set; } = null!;
|
||||
public Dictionary<string, object>? UserMeta { get; set; } = null!;
|
||||
public Dictionary<string, object?> FileMeta { get; set; } = null!;
|
||||
public Dictionary<string, object?> UserMeta { get; set; } = null!;
|
||||
public string? MimeType { get; set; }
|
||||
public string? Hash { get; set; }
|
||||
public long Size { get; set; }
|
||||
public bool HasCompression { get; set; } = false;
|
||||
|
||||
public static CloudFileReferenceObject FromProtoValue(Proto.CloudFile proto)
|
||||
{
|
||||
return new CloudFileReferenceObject
|
||||
{
|
||||
Id = proto.Id,
|
||||
Name = proto.Name,
|
||||
FileMeta = proto.FileMeta
|
||||
.ToDictionary(kvp => kvp.Key, kvp => GrpcTypeHelper.ConvertField(kvp.Value)),
|
||||
UserMeta = proto.UserMeta
|
||||
.ToDictionary(kvp => kvp.Key, kvp => GrpcTypeHelper.ConvertField(kvp.Value)),
|
||||
MimeType = proto.MimeType,
|
||||
Hash = proto.Hash,
|
||||
Size = proto.Size,
|
||||
HasCompression = proto.HasCompression
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the current object to its protobuf representation
|
||||
/// </summary>
|
||||
|
@@ -26,7 +26,7 @@ public interface ICloudFile
|
||||
/// <summary>
|
||||
/// Gets the file metadata dictionary.
|
||||
/// </summary>
|
||||
Dictionary<string, object>? FileMeta { get; }
|
||||
Dictionary<string, object?> FileMeta { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user metadata dictionary.
|
||||
|
@@ -75,7 +75,7 @@ public abstract class GrpcTypeHelper
|
||||
return result;
|
||||
}
|
||||
|
||||
private static object? ConvertField(Value value)
|
||||
public static object? ConvertField(Value value)
|
||||
{
|
||||
return value.KindCase switch
|
||||
{
|
||||
|
@@ -51,10 +51,6 @@ message AccountProfile {
|
||||
int32 level = 15;
|
||||
double leveling_progress = 16;
|
||||
|
||||
// Legacy fields
|
||||
google.protobuf.StringValue picture_id = 17;
|
||||
google.protobuf.StringValue background_id = 18;
|
||||
|
||||
CloudFile picture = 19;
|
||||
CloudFile background = 20;
|
||||
|
||||
|
@@ -58,15 +58,6 @@ service FileService {
|
||||
// Delete a file reference
|
||||
rpc DeleteFile(DeleteFileRequest) returns (google.protobuf.Empty);
|
||||
|
||||
// Process and upload a new file
|
||||
rpc ProcessNewFile(stream ProcessNewFileRequest) returns (CloudFile);
|
||||
|
||||
// Upload a file to remote storage
|
||||
rpc UploadFileToRemote(stream UploadFileToRemoteRequest) returns (CloudFile);
|
||||
|
||||
// Delete file data from storage
|
||||
rpc DeleteFileData(DeleteFileDataRequest) returns (google.protobuf.Empty);
|
||||
|
||||
// Load files from references
|
||||
rpc LoadFromReference(LoadFromReferenceRequest) returns (LoadFromReferenceResponse);
|
||||
|
||||
@@ -88,14 +79,6 @@ message UpdateFileRequest {
|
||||
google.protobuf.FieldMask update_mask = 2;
|
||||
}
|
||||
|
||||
// Request message for DeleteFile
|
||||
message ProcessNewFileRequest {
|
||||
oneof data {
|
||||
FileMetadata metadata = 1;
|
||||
bytes chunk = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message FileMetadata {
|
||||
string file_id = 1;
|
||||
string file_name = 2;
|
||||
@@ -103,13 +86,6 @@ message FileMetadata {
|
||||
string account_id = 4;
|
||||
}
|
||||
|
||||
message UploadFileToRemoteRequest {
|
||||
oneof data {
|
||||
UploadMetadata metadata = 1;
|
||||
bytes chunk = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message UploadMetadata {
|
||||
string file_id = 1;
|
||||
string target_remote = 2;
|
||||
@@ -122,11 +98,6 @@ message DeleteFileRequest {
|
||||
bool purge = 2;
|
||||
}
|
||||
|
||||
message DeleteFileDataRequest {
|
||||
string file_id = 1;
|
||||
bool force = 2;
|
||||
}
|
||||
|
||||
message LoadFromReferenceRequest {
|
||||
repeated string reference_ids = 1;
|
||||
}
|
||||
@@ -201,7 +172,7 @@ message GetResourceReferencesRequest {
|
||||
|
||||
message GetResourceFilesRequest {
|
||||
string resource_id = 1;
|
||||
string usage = 2; // Optional
|
||||
optional string usage = 2;
|
||||
}
|
||||
|
||||
message GetResourceFilesResponse {
|
||||
@@ -210,7 +181,7 @@ message GetResourceFilesResponse {
|
||||
|
||||
message DeleteResourceReferencesRequest {
|
||||
string resource_id = 1;
|
||||
string usage = 2; // Optional
|
||||
optional string usage = 2;
|
||||
}
|
||||
|
||||
message DeleteResourceReferencesResponse {
|
||||
|
Reference in New Issue
Block a user