public Blob(Guid id, string entityType, string entityId, BasicBlobInfo blobInfo, Guid?tenantId) { Id = id; EntityType = entityType; EntityId = entityId; ContainerName = blobInfo.ContainerName; BlobName = blobInfo.BlobName; BinarySize = blobInfo.BinarySize; Hash = blobInfo.Hash; ReferBlobName = blobInfo.ReferBlobName; TenantId = tenantId; }
public async Task CreateAsync(BasicBlobInfo blobInfo, CancellationToken cancellationToken = default) { var blobEntityResult = await _blobEntityResolver.ResolveBlobEntityAsync(); Check.NotNullOrWhiteSpace(blobEntityResult.EntityType, nameof(blobEntityResult.EntityType), BlobConsts.MaxEntityTypeLength); Check.NotNullOrWhiteSpace(blobEntityResult.EntityId, nameof(blobEntityResult.EntityId), BlobConsts.MaxEntityIdLength); Check.NotNullOrWhiteSpace(blobInfo.ContainerName, nameof(blobInfo.ContainerName), BlobConsts.MaxContainerNameLength); Check.NotNullOrWhiteSpace(blobInfo.BlobName, nameof(blobInfo.BlobName), BlobConsts.MaxBlobNameLength); if (!_options.Value.EntityTypes.Any(x => x.EntityType == blobEntityResult.EntityType)) { throw new EntityBlobNotAddableException(blobEntityResult.EntityType); } var blob = new Blob( GuidGenerator.Create(), blobEntityResult.EntityType, blobEntityResult.EntityId, blobInfo, CurrentTenant.Id); await _blobRepository.InsertAsync(blob, cancellationToken : cancellationToken); }