Beispiel #1
0
        public async Task <DeviceIcon> AddIcon(string fileName, Stream fileStream)
        {
            await CreateAccessPolicyIfNotExist();

            string name         = Guid.NewGuid().ToString();
            string extension    = Path.GetExtension(fileName);
            string contentType  = MimeMapping.GetMimeMapping(string.IsNullOrEmpty(extension) ? "image/png" : extension);
            var    uploadedBlob = await _blobStorageClient.UploadFromStreamAsync($"{_uploadedFolder}/{name}",
                                                                                 contentType,
                                                                                 fileStream,
                                                                                 AccessCondition.GenerateEmptyCondition(),
                                                                                 null,
                                                                                 null);

            var appliedBlob = await _blobStorageClient.MoveBlob(uploadedBlob.Name, $"{_appliedFolder}/{name}");

            return(new DeviceIcon(Path.GetFileName(appliedBlob.Name), appliedBlob));
        }