| | | 1 | | namespace Chronicis.Api.Services; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Service for managing Azure Blob Storage operations for world documents. |
| | | 5 | | /// </summary> |
| | | 6 | | public interface IBlobStorageService |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Generate a SAS URL for uploading a file directly from the client. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="worldId">The world ID for scoping the blob path.</param> |
| | | 12 | | /// <param name="documentId">The document ID (pre-created).</param> |
| | | 13 | | /// <param name="fileName">The original filename.</param> |
| | | 14 | | /// <param name="contentType">The MIME type of the file.</param> |
| | | 15 | | /// <returns>SAS URL valid for 15 minutes with write-only permissions.</returns> |
| | | 16 | | Task<string> GenerateUploadSasUrlAsync(Guid worldId, Guid documentId, string fileName, string contentType); |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Verify that a blob exists and get its metadata. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <param name="blobPath">The blob path to verify.</param> |
| | | 22 | | /// <returns>Metadata including size and content type, or null if not found.</returns> |
| | | 23 | | Task<BlobMetadata?> GetBlobMetadataAsync(string blobPath); |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Open a read-only stream for the blob content. |
| | | 27 | | /// </summary> |
| | | 28 | | /// <param name="blobPath">The blob path to read.</param> |
| | | 29 | | /// <returns>Stream for reading the blob content.</returns> |
| | | 30 | | Task<Stream> OpenReadAsync(string blobPath); |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Delete a blob from storage. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <param name="blobPath">The blob path to delete.</param> |
| | | 36 | | Task DeleteBlobAsync(string blobPath); |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Generate a SAS URL for downloading a file directly from the client. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <param name="blobPath">The blob path to generate download URL for.</param> |
| | | 42 | | /// <returns>SAS URL valid for 15 minutes with read-only permissions.</returns> |
| | | 43 | | Task<string> GenerateDownloadSasUrlAsync(string blobPath); |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Build the blob path for a document. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <param name="worldId">The world ID.</param> |
| | | 49 | | /// <param name="documentId">The document ID.</param> |
| | | 50 | | /// <param name="fileName">The sanitized filename.</param> |
| | | 51 | | /// <returns>The blob path.</returns> |
| | | 52 | | string BuildBlobPath(Guid worldId, Guid documentId, string fileName); |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Metadata about a blob in storage. |
| | | 57 | | /// </summary> |
| | | 58 | | public class BlobMetadata |
| | | 59 | | { |
| | 0 | 60 | | public long SizeBytes { get; set; } |
| | 0 | 61 | | public string ContentType { get; set; } = string.Empty; |
| | | 62 | | } |