Esempio n. 1
0
        public PhotoCloudUploadResult UploadPhotoToCloud(IFormFile photo)
        {
            var uploadResult = new ImageUploadResult();

            using (var stream = photo.OpenReadStream())
            {
                var uploadParams = new ImageUploadParams()
                {
                    File = new FileDescription(photo.Name, stream),
                };

                uploadResult = _cloudinary.Upload(uploadParams);
            }

            var result = new PhotoCloudUploadResult
            {
                PublicId = uploadResult.PublicId,
                Url      = uploadResult.Url.ToString()
            };

            return(result);
        }
Esempio n. 2
0
        private void InitializeObjects()
        {
            _service = new PhotoService(_cloudUploadService.Object, _mapper.Object, _uow.Object);

            _photoForCreation = new PhotoForCreationDto
            {
                File         = new Mock <IFormFile>().Object,
                Description  = "description",
                EntityTypeId = (int)EntityTypes.Film,
                EntityId     = 1
            };

            _uploadResult = new PhotoCloudUploadResult
            {
                PublicId = "PublicId",
                Url      = "Url"
            };

            _photo = new Domain.Entities.Photo();

            _mainPhoto = new Domain.Entities.Photo();

            _photos = new List <Domain.Entities.Photo>();

            _photosForDetailed = new List <PhotoForDetailedDto>
            {
                new PhotoForDetailedDto {
                },
                new PhotoForDetailedDto {
                }
            };

            _mainPhotoUploadable = new MainPhotoUploadable
            {
                Id = 1
            };
        }