예제 #1
0
        public async Task <long> CreateBlobAsync(long tenantId, IBlobContent content)
        {
            // Construct blob object
            bool isImage = ContentTypeIsImage(content.Type);
            Blob blob    = isImage ? GetBlobImage(content) : new Blob()
            {
                BlobType = BlobType.Document
            };
            DateTime utcNow = DateTime.UtcNow;

            blob.ContentType = content.Type;
            blob.Created     = utcNow;
            blob.Name        = content.Name;
            blob.Path        = UncommittedPath;
            blob.Size        = (int)content.Stream.Length;
            blob.TenantId    = tenantId;
            blob.Updated     = utcNow;

            // Create blob record and get back newly allocated blob identifier
            blob.BlobId = isImage ? await _storageRepository.CreateBlobImageAsync(tenantId, (BlobImage)blob) : await _storageRepository.CreateBlobAsync(tenantId, blob);

            // Create blob content
            await _blobService.CreateBlobContentAsync(blob, content.Stream);

            // Return newly allocated blob identifier
            return(blob.BlobId);
        }
예제 #2
0
        public async Task <long> CreateBlobAsync(long tenantId, Blob blob, Stream stream)
        {
            DateTime utcNow = DateTime.UtcNow;

            blob.Created = utcNow;
            blob.Updated = utcNow;
            blob.Size    = (int)stream.Length;
            if (blob.Path == null)
            {
                blob.Path = string.Empty;
            }

            if (ContentTypeIsImage(blob.ContentType))
            {
                blob = GetBlobImage(blob, stream);
            }

            blob.BlobId = await _storageRepository.CreateBlobAsync(tenantId, blob);

            await _blobService.CreateBlobContentAsync(blob, stream);

            return(blob.BlobId);
        }