コード例 #1
0
        private static AnswerCV GetEncodedCv(string resumeFileName, FileContents resumeContents)
        {
            using (var stream = resumeContents.GetStream())
            {
                var length = (int)stream.Length;
                var buffer = new byte[length];
                stream.Read(buffer, 0, length);

                return(new AnswerCV
                {
                    Filename = resumeFileName,
                    Value = Convert.ToBase64String(buffer)
                });
            }
        }
コード例 #2
0
        FileReference IEmployerLogosCommand.SaveLogo(FileContents fileContents, string fileName)
        {
            var extension = Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }
            extension = extension.TrimStart('.');
            if (!_imagesCommand.IsValidFileExtension(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }

            // Save it after cropping it to an appropriate size.

            using (var stream = _imagesCommand.Crop(fileContents.GetStream(), Roles.JobAds.Constants.LogoMaxSize, _imagesCommand.GetFormat(extension)))
            {
                return(_filesCommand.SaveFile(FileType.CompanyLogo, new StreamFileContents(stream), fileName));
            }
        }
コード例 #3
0
ファイル: MemberPhotosCommand.cs プロジェクト: formist/LinkMe
        FileReference IMemberPhotosCommand.SavePhoto(FileContents fileContents, string fileName)
        {
            var extension = Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }
            extension = extension.TrimStart('.');
            if (!_imagesCommand.IsValidFileExtension(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }
            fileName = Path.ChangeExtension(fileName, StorageExtension);

            // Save it after converting it to an appropriate size and format.

            using (var stream = _imagesCommand.Resize(fileContents.GetStream(), Domain.Contacts.Constants.PhotoMaxSize, StorageFormat))
            {
                return(_filesCommand.SaveFile(FileType.ProfilePhoto, new StreamFileContents(stream), fileName));
            }
        }