Beispiel #1
0
        public void UploadStroke(StrokeDto strokeDto)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("StorageConnectionString"));

            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve a reference to a container.
            CloudBlobContainer container = blobClient.GetContainerReference("user-" + strokeDto.UserId.ToString());
            container.CreateIfNotExists();

            var blobName = GetVideoName(strokeDto);
            CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);

            blockBlob.UploadFromStream(strokeDto.StrokeVideo);
        }
Beispiel #2
0
        public StrokesModule()
            : base("/strokes")
        {
            //commentss
            Get["/forehand"] = parameters =>
            {
                var viewModel = new StrokesViewModel();

                return View["strokes", viewModel];
            };

             Get["/backhand"] = parameters =>
            {
                var viewModel = new StrokesViewModel();

                return View["strokes", viewModel];
            };

             Get["/serve"] = parameters =>
            {
                var viewModel = new StrokesViewModel();

                viewModel.UserStrokeUrl = "https://tennisvids.blob.core.windows.net/serves/WP_20130706_003.mp4";

                return View["strokes", viewModel];
            };

             Get["/upload"] = parameters =>
             {
                 var viewModel = new StrokesViewModel();

                 return View["upload", viewModel];
             };

             Post["/upload"] = parameters =>
             {
                 var viewModel = new StrokesViewModel();
                 var strokesDto = new StrokeDto();

                 var file = this.Request.Files.FirstOrDefault();

                 if (file != null)
                 {
                     strokesDto.UserId = 1;
                     strokesDto.StrokeVideo = file.Value;
                     strokesDto.StrokeType = (StrokeType)((int)Request.Form.StrokeType);
                     strokesDto.StrokeAngle = (StrokeAngle)((int)Request.Form.StrokeAngle);

                     var strokesBizObj = new Strokes();
                     strokesBizObj.UploadStroke(strokesDto);

                     viewModel.IsSuccessfulUpload = true;

                 }
                 else
                 {

                 }

                 return View["upload", viewModel];
             };
        }
Beispiel #3
0
 private string GetVideoName(StrokeDto strokeDto)
 {
     var strokeType = Enum.GetName(typeof(StrokeType), (int)strokeDto.StrokeType);
     var strokeAngle = Enum.GetName(typeof(StrokeAngle), (int)strokeDto.StrokeAngle);
     return string.Format("{0}-{1}-{2}", strokeDto.UserId.ToString(), strokeType.ToLower(), strokeAngle.ToLower());
 }