/// <summary>
        /// Converts the section to a form section
        /// </summary>
        /// <param name="section">The section to convert</param>
        /// <returns>A form section</returns>
        public static FormMultipartSection AsFormDataSection(this MultipartSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            try {
                return(new FormMultipartSection(section));
            } catch {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="FileMultipartSection"/> class
        /// </summary>
        /// <param name="section">The section from which to create the <see cref="FileMultipartSection"/></param>
        /// <param name="header">An already parsed content disposition header</param>
        public FileMultipartSection(MultipartSection section, ContentDispositionHeaderValue header)
        {
            if (!header.IsFileDisposition())
            {
                throw new ArgumentException($"Argument must be a file section", nameof(section));
            }

            Section = section;
            _contentDispositionHeader = header;

            Name     = HeaderUtilities.RemoveQuotes(_contentDispositionHeader.Name).ToString();
            FileName = HeaderUtilities.RemoveQuotes(
                _contentDispositionHeader.FileNameStar.HasValue ?
                _contentDispositionHeader.FileNameStar :
                _contentDispositionHeader.FileName).ToString();
        }
Пример #3
0
 /// <summary>
 /// Creates a new instance of the <see cref="FileMultipartSection"/> class
 /// </summary>
 /// <param name="section">The section from which to create the <see cref="FileMultipartSection"/></param>
 /// <remarks>Reparses the content disposition header</remarks>
 public FileMultipartSection(MultipartSection section)
     : this(section, section.GetContentDispositionHeader())
 {
 }