コード例 #1
0
        public AssetStorageMetadata StoreAsset(string assetName, string videoName, string contentType, byte[] assetContents)
        {
            var asset     = _context.Assets.Create(assetName, AssetCreationOptions.None);
            var assetFile = asset.AssetFiles.Create(videoName);

            assetFile.ContentFileSize = assetContents.Length;

            var uploadLocator = _mediaServices.CreateSasLocator(asset, _mediaServices.UploadPolicy);

            var destinationContainerName = (new Uri(uploadLocator.Path)).Segments[1];

            _blobStorage.AddFileToBlobStorage(destinationContainerName, videoName, contentType, assetContents);
            assetFile.Update();

            _mediaServices.UploadPolicy.Delete();

            var publicLocator = _mediaServices.CreateSasLocator(asset, _mediaServices.PublicPolicy);

            var metadata = new AssetStorageMetadata
            {
                Id              = assetName,
                StorageId       = asset.Id,
                StorageLocation = publicLocator.Path
            };

            return(metadata);
        }
コード例 #2
0
        private AssetMetadata StoreMetadata(AssetStorageMetadata storageMetadata)
        {
            var assetMetadata = new AssetMetadata
            {
                Id              = Id,
                Name            = Name,
                Description     = Description,
                ContentType     = WebFile.ContentType,
                Url             = storageMetadata.StorageLocation,
                StorageMetadata = storageMetadata,
                Type            = AssetTypeMapping.GetTypeFor(WebFile.ContentType)
            };

            _assetDocumentRepository.Create(assetMetadata);

            return(assetMetadata);
        }
コード例 #3
0
        public AssetStorageMetadata StoreAsset(string id, string fileName, string contentType, byte[] fileBytes)
        {
            if (fileBytes == null)
            {
                return(null);
            }

            var storageFileName = _blobStorage.GetStorageFileName(id, fileName);

            var metadata = new AssetStorageMetadata
            {
                Id        = id,
                StorageId = storageFileName
            };

            _blobStorage.AddFileToBlobStorage(_containerName, metadata.StorageId, contentType, fileBytes);

            return(metadata);
        }