Exemplo n.º 1
0
        public UploadReturnResult UploadPhoto(string keyName, MemoryStream stream)
        {
            var uploadReturnResult = new UploadReturnResult {
                Message = string.Empty, Success = false
            };

            try
            {
                var storageacc = CloudStorageAccount.Parse(connectionString);
                var blobClient = storageacc.CreateCloudBlobClient();
                var container  = blobClient.GetContainerReference("photos");
                var photoBlob  = container.GetBlockBlobReference(keyName);
                photoBlob.Properties.ContentType = "image/png";
                photoBlob.UploadFromStream(stream);
                uploadReturnResult.Success = true;
            }
            catch (Exception e)
            {
                uploadReturnResult.Message = e.Message;
                uploadReturnResult.Success = false;
            }
            return(uploadReturnResult);
        }
Exemplo n.º 2
0
        public async Task <UploadReturnResult> UploadWebcamVideo(string keyName, MemoryStream stream)
        {
            var uploadReturnResult = new UploadReturnResult {
                Message = string.Empty, Success = false
            };

            try
            {
                var storageacc = CloudStorageAccount.Parse(connectionString);
                var blobClient = storageacc.CreateCloudBlobClient();
                var container  = blobClient.GetContainerReference("videos");
                var videoBlob  = container.GetBlockBlobReference(keyName + ".webm");
                videoBlob.Properties.ContentType = "video/webm";
                videoBlob.UploadFromStream(stream);
                uploadReturnResult.Success = true;
            }
            catch (Exception e)
            {
                uploadReturnResult.Message = e.Message;
                uploadReturnResult.Success = false;
            }
            return(uploadReturnResult);
        }