GetFileMimeType() public static method

public static GetFileMimeType ( string fileName ) : string
fileName string
return string
Example #1
0
        public ByteFile(byte[] data, string fileName, string mimeType = null)
        {
            if (data.Length == 0)
            {
                throw new ArgumentException("Argument is empty collection", nameof(data));
            }

            Data     = data;
            FileName = fileName ?? "file";
            MimeType = mimeType ?? BinaryType.GetFileMimeType(FileName);
        }
Example #2
0
        public ByteFile(string filePath)
        {
            if (File.Exists(filePath))
            {
                Data = File.ReadAllBytes(filePath);
                if (Data.Length > MaxFileSize)
                {
                    throw new Exception("file is above {MaxFileSize} bytes. ");
                }

                FileName = System.IO.Path.GetFileName(filePath);
                MimeType = BinaryType.GetFileMimeType(filePath);
            }
            else
            {
                throw new FileNotFoundException("File is not exists", nameof(filePath));
            }
        }
Example #3
0
 public BytePostParameter(string name, byte[] value, string fileName = null, string mimeType = null)
     : base(name, value)
 {
     FileName = fileName ?? "attachment";
     MimeType = mimeType ?? BinaryType.GetFileMimeType(FileName);
 }