コード例 #1
0
        public async Task <WebHttpResponse <bool> > Upload([FromForm] InsertVideoDto video)
        {
            WebHttpResponse <bool> response = new WebHttpResponse <bool>();

            try
            {
                var filePath = Path.Combine(@"C:\Users\c.wijesinghe\Desktop\SimplifiedYouTube\Solution\01 Clients\Capgemini.SimplifiedYouTube.Clients.ReactApp\ClientApp\public\videos", video.File.FileName); //we are using Temp file name just for the example. Add your own file path.

                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    await video.File.CopyToAsync(stream);
                }

                var result = _videosFacade.Insert(video);

                if (result)
                {
                    response.Data         = true;
                    response.ResponseCode = Kaddis.Framework.Utilities.Entities.StatusCode.OK;
                }
                else
                {
                    response.Data         = false;
                    response.ResponseCode = Kaddis.Framework.Utilities.Entities.StatusCode.BadRequest;
                }
            }
            catch (Exception ex)
            {
                response.Data         = false;
                response.ResponseCode = Kaddis.Framework.Utilities.Entities.StatusCode.InternalServerError;
                response.Messages     = ex.Message;
            }

            return(response);
        }
コード例 #2
0
        public bool Insert(InsertVideoDto video)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new Common.Protos.Videos.Videos.VideosClient(channel);
            var reply  = client.Insert(
                new InsertRequest {
                Name        = video.Name,
                Description = video.Description,
                FileName    = video.File.FileName
            });

            return(reply.Response);
        }